<template>
    <div class="page_container">
        <div class="bg-breadcrumb">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item> 开发管理 </el-breadcrumb-item>
                <el-breadcrumb-item > 系统账号管理 </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
         <div class="flex_row">
           <div class="flex_left bgc_white">
             <div class="tree_header">
                 政务机构
             </div>
             <div class="tree_content">
               <div class="search"> 
                 <el-input
                    v-model="search"
                    placeholder="请输入组织名称搜索"
                    :prefix-icon="Search"
                  />
               </div>
               <div class="tree">
                 <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick" :default-expand-all="true" />
               </div>
             </div>
           </div>
           <div class="flex_right bgc_white">
             <div class="main_container">
              <div class="apaas_button">
                <el-button type="primary" @click="addAccount(0)">新建</el-button><el-button @click="addAccount(1)">编辑</el-button>
              </div>
                <div class="table_container apaas_scroll">
                  <bg-table ref="bgTable" :headers="headers" :rows="tableRows" :isIndex="true" :stripe="true">
                    <template v-slot:action="{ row }">
                      <bg-table-btn class="btn">
                        编辑
                      </bg-table-btn>
                      <bg-table-btn class="btn">
                        修改密码
                      </bg-table-btn>
                      <bg-table-btn class="btn">
                        删除
                      </bg-table-btn>
                    </template>
                  </bg-table>
                  <div class="pagination_box">
                     <bg-pagination
                    :page="1"
                    :size="10"
                    :total="100"
                    @change-page="changePage"
                    @change-size="changeSize"
                  >
                  </bg-pagination>
                  </div>
                  
                </div>
                 
              </div>
           </div>
        </div>
    </div>
</template>

<script setup>
import { Search } from '@element-plus/icons-vue'
import { reactive, toRefs, ref, } from '@vue/reactivity'
import { getCurrentInstance } from 'vue'
import { computed, onBeforeMount } from '@vue/runtime-core'
import { useRouter } from 'vue-router';

  const headers = ref([
        {
          label: "业务系统编码",
          prop: "code",
          width: 180
        },
        {
          label: "业务系统名称",
          prop: "name",
          minWidth: 180
        },
        {
          label: "账号",
          prop: "account",
          width: 150
        },
        {
          label: "所属机构",
          prop: "org",
          width: 240
        },
        {
          label: "创建时间",
          prop: "create_time",
          width: 150
        },
        {
          label: "是否启用",
          prop: "is_use",
          width: 80
        },
        {
          label: "操作",
          prop: "action",
          width: 220,
          fixed: "right",
        },
      ])
  const tableRows = ref([
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
    {code: "YWXT0000001",name: "大数据处理系统",account: "admin",org: "大数据局",create_time: "2022-01-01 00:00",is_use: "是"},
  ])
  const search=ref("");

  const router = useRouter();
  onBeforeMount(() => {
   
  })

  const addAccount = (params) => {
    router.push({
        path: "/develop/account/add",
        query: {
          type: params
        }
      })
  }

  const handleNodeClick = (data) => {
    console.log(data)
  }

  const data = [
    {
      label: '湖北省',
      children: [
        {
          label: '武汉市',
          children: [
            {
              label: '公安厅公安厅公安厅公安厅公安厅公安厅公安厅公安厅公安厅公安厅公安厅公安厅公安厅公安厅公安厅',
            },
            {
              label: '应急厅',
            },
            {
              label: '水利厅',
            },
          ],
        },
        {
          label: '荆州市',
          children: [
            {
              label: '公安局',
            },
            {
              label: '应急管理局',
            },
          ],
        }
      ],
    },
    {
      label: '四川省',
      children: [
        {
          label: '成都市',
          children: [
            {
              label: '天府新区',
            },
          ],
        },
      ],
    },
    {
      label: '比格大数据',
      children: [
        {
          label: '武汉研发中心',
          children: [
            {
              label: '研发部',
            },
          ],
        },
        {
          label: '西南大区',
          children: [
            {
              label: '事业部',
            },
            {
              label: '事业部',
            },
            {
              label: '事业部',
            },
            {
              label: '事业部',
            },
            {
              label: '事业部',
            },
            {
              label: '事业部',
            },
            {
              label: '事业部',
            },
          ],
        },
      ],
    },
  ]

  const defaultProps = {
    children: 'children',
    label: 'label',
  }

   const changeSize = (size) => {

    }

    const changePage = (size) => {

    }


</script>

<style scoped>
.tree_header {
  height: 40px;
  line-height: 40px;
	background-color: #f7f7f9;
	border-radius: 6px 6px 0px 0px;
  font-size: 16px;
	letter-spacing: 0px;
	color: #202531;
  padding-left: 16px;
}
.tree_content {
  overflow: hidden;
  height: calc(100% - 45px);
}
.search {
  padding: 16px;
}
.tree {
  overflow: auto;
  height: calc(100% - 65px);
  padding: 5px;
}
.tree :deep() .el-tree-node>.el-tree-node__children {
  overflow: unset;
}
.main_container {
  padding: 15px;
  height: 100%;
}
.table_container {
  height: calc(100% - 30px);
  overflow: auto;
}
.pagination_box {
  position: sticky;
  position: -webkit-sticky;
  margin-top: 16px;
  bottom: 0px;
  background-color: #fff;
  z-index: 1024;
  height: 40px;
  line-height: 40px;
  padding-top: 8px;
}
.bg-pagination {
  bottom: unset
}

</style>