<!--
@ 作者: 秦东
@ 时间: 2025-11-28 10:11:16
@ 备注: 人员列表
-->
<script lang='ts' setup>
import { emptypeOptions } from "@/api/hr/people/datacont";
import { orgInfo } from "@/api/hr/org/type";
import { authorizeOrgTree } from '@/api/system/roleapi/power'
import {
  teamcontlist
} from "@/api/hr/org/index";

const orgTreeRef = ref(ElTree); //行政组织树
const orgTreeLoading = ref(false); //加载行政组织树
const orgTreeList = ref<orgInfo[]>(); //行政组织树数据
const tiemList = ref([]); //班组列表
const orgTreeProps = {
  children: "child",
  label: "name",
}; //行政组织树对照值

const searchInfo = reactive({
    orgId:"",
    name:"",
    employ:"",
    team:"",
    joinTime:""
})

const getOrgPowerTrue =  () => {
    orgTreeLoading.value = true
    let sendInfo = {
        menuId:"50"
    }
    authorizeOrgTree(sendInfo).then((res) => {
        console.log(res)
        orgTreeList.value = res.data
        orgTreeLoading.value = false
    }).finally(() => {
        orgTreeLoading.value = false
    })
}
/**
@ 作者: 秦东
@ 时间: 2025-01-14 10:27:12
@ 功能: 获取班组列表
*/
const gainTimeList = () => {
  let searchMap = {
    page: 1,
    pagesize: 2000,
    name: "",
  };
  teamcontlist(searchMap).then((data) => {
    tiemList.value = data.data.list;
  });
};
const resetChecked = () => {
    orgTreeRef.value.setCheckedKeys([])
}
/**
 * 选中行政组织树节点
 */
const handleOrgTreeNodeClick = (data: orgInfo) => {
  // console.log(data)
  searchInfo.orgId = data.id;
//   getArchivesPage();
};
onMounted(() => {
    getOrgPowerTrue();
    gainTimeList();
})
</script>
<template>
  <div class="app-content">
    <el-container>
        <el-aside width="300px" style="padding: 10px 10px">
            <el-card :body-style="{ height: 'calc(100vh - 190px)', padding: '0px 5px' }">
                <el-button
                    type="primary"
                    style="width: 100%; margin: 10px 0"
                    @click="resetChecked"
                >
                查看全部
                </el-button>
                <el-tree-v2
                    style="max-width: 100%"
                    :data="orgTreeList"
                    :props="orgTreeProps"
                    v-loading="orgTreeLoading"
                    node-key="id"
                    :expand-on-click-node="false"
                    :check-on-click-node="true"
                    :check-strictly="true"
                    :default-expand-all="false"
                    :height="1200"
                    @node-click="handleOrgTreeNodeClick"
                />
            </el-card>
        </el-aside>



        <el-main style="padding: 10px 10px 0 0">
            <el-card :body-style="{ height: 'calc(100vh - 190px)', padding: '0px 15px' }">
                <el-form ref="searchForm" :model="searchInfo" :inline="true" style="width: 100%; margin-top: 10px;">
                    <el-form-item label="工号 / 姓名 / 手机号" prop="keywords">
                        <el-input
                            v-model="searchInfo.name"
                            placeholder="请输入工号/姓名/手机号"
                            clearable
                        />
                    </el-form-item>
                    <el-form-item label="用工关系" prop="number">
                        <el-select
                            v-model="searchInfo.employ"
                            multiple
                            clearable
                            collapse-tags
                            placeholder="用工关系"
                            style="width: 200px"
                        >
                            <el-option
                                v-for="item in emptypeOptions"
                                :key="item.id"
                                :label="item.name"
                                :value="item.id"
                            />
                        </el-select>
                    </el-form-item>
                    <el-form-item label="班组" prop="number">
                        <el-select
                            v-model="searchInfo.team"
                            clearable
                            collapse-tags
                            placeholder="员工班组"
                            style="width: 240px"
                        >
                            <el-option
                            v-for="item in tiemList"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id"
                            />
                        </el-select>
                    </el-form-item>
                    <el-form-item label="入职日期" prop="number">
                        <el-date-picker
                            v-model="searchInfo.joinTime"
                            type="date"
                            placeholder="入职日期"
                            format="YYYY-MM-DD"
                            value-format="YYYY-MM-DD"
                        />
                    </el-form-item>
                    <el-form-item label="" prop="number">
                        <el-button type="primary" @click="getArchivesPage">
                            <template #icon><i-ep-search /></template>
                            搜索
                        </el-button>
                        <el-button @click="resetArcFormQuery">
                            <template #icon><i-ep-refresh /></template>
                            重置
                        </el-button>
                    </el-form-item>
                </el-form>
                <div class="func-but">
                    <el-button v-hasButton="[215437071358111744]" type="primary" @click="handleAddArchives">
                        <template #icon><i-ep-plus /></template>
                        新增
                    </el-button>
                    <el-button
                        v-hasPerm="['215437153071542272']"
                        plain
                        type="primary"
                        @click="openPiliangBox"
                    >
                        <el-icon><MessageBox /></el-icon>
                        批量导入数据
                    </el-button>
                </div>
            </el-card>
        </el-main>
    </el-container>
  </div>
</template>
<style  lang='scss' scoped>
.app-content {
    height: calc(100vh - 170px);
    background-color: aqua;

  :deep .el-drawer__body {
    padding: 0 10px;
  }
}
.common-layout {
  
}
</style>
