<template>
    <BasicTable @register="registerTable" :rowSelection="rowSelection" @selection-change="handlerRowClick">
        <!-- update-begin-author:taoyan date:2022-5-25 for: VUEN-1112一对多 用户选择 未显示选择条数，及清空 -->
        <template #tableTitle></template>
        <!-- update-end-author:taoyan date:2022-5-25 for: VUEN-1112一对多 用户选择 未显示选择条数，及清空 -->
    </BasicTable>
</template>
<script setup>
import { toRaw } from 'vue';
import { BasicTable } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { list } from '/@/views/project/base/StSysManage.api';

const props = defineProps({
    actCheckbox: {},
});
const columns = [
   {
    title: '系统名称',
    align:"left",
    dataIndex: 'sysName'
   },
   {
    title: '说明',
    align:"left",
    dataIndex: 'sysDes'
   },
];
const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
      tableProps:{
           title: '',
           api: list,
           columns,
           canResize:false,
           useSearchForm: false,
           scroll: { x: false,y:250 },
           actionColumn: {ifShow: false},
           clickToRowSelect: true,
           rowSelection: { 
                onSelect: handlerChecked,
            },
        //    actionColumn: {
        //        width: 160
        //     },
            showTableSetting: false,
      },
  })
  const [registerTable, {setProps,reload},{ rowSelection, selectedRowKeys }] = tableContext

  function handlerChecked(record, selected, selectedRows, nativeEvent){
    if(selected){
        let item = {}
        item[record.id] = true
        Object.assign(props.actCheckbox,item)
    }else{
        let item = {}
        item[record.id] = false
        Object.assign(props.actCheckbox,item)
    }
  }
  function initActCheckbox(){
    let actInfo = toRaw(props.actCheckbox)
    let item = {}
    for(let k in actInfo){
        console.log(k)
        item[k] = false
    }
    Object.assign(props.actCheckbox,item)
  }
  function handlerRowClick({keys,rows}){
    initActCheckbox()
    if(keys.length>0){
        let item = {}
        for(var i=0;i<keys.length;i++){
            item[rows[i].id] = true
        }
        Object.assign(props.actCheckbox,item)
    }
  }
</script>