
<template>
  <HcCard>
    <template #header>
      <div class="w-36 ml-2">
                <el-select v-model="searchForm.peoplename" block clearable placeholder="员工姓名" size="large">
                    <el-option v-for="item in peopleoption" :label="item.name" :value="item.key"/>
                </el-select>
      </div>
      <div class="w-36 ml-2">
        <el-date-picker v-model="searchForm.month" class="block" size="large" type="month" @change="datePickerChange"  placeholder="选择月份" />
      </div>
      <div class="ml-4">
                <el-button type="primary" @click="searchClick" size="large">
                    <HcIcon name="search-2"/>
                    <span>搜索</span>
                </el-button>
       </div>
      <div class="ml-2">
                <el-button size="large" @click="resetClick">
                    <HcIcon name="close-circle"/>
                    <span>重置</span>
                </el-button>
        </div>
    </template>
    <template  #extra>
        <el-button type="primary" @click="downloadXlsx" size="large">
                    <HcIcon name="download-2"/>
                    <span>下载模板</span>
         </el-button>
         <el-button type="primary" @click="toImportTempClick" size="large" class="ml-2">
                    <HcIcon name="folder-upload"/>
                    <span>导入数据</span>
         </el-button>
    </template>
    <HcTable :column="tableColumn" :datas="tableData" >
        
      </HcTable>
      <template #action>
            <HcPages :pages="searchForm" @change="pageChange"></HcPages>
      </template>
            <!--导入数据弹窗-->
            <HcDialog bgColor="#ffffff" widths="34rem" isToBody  :show="importModal" title="导入数据" @close="importModalClose" footer isRowFooter>
                        <el-form label-position="top" label-width="auto" :model="formModel" size="large">
                            <el-form-item label="请选择导入薪酬所时间属范围：">
                              <el-date-picker
                                v-model="formModel.time"
                                type="daterange"
                                start-placeholder="起始时间"
                                end-placeholder="结束时间"
                                :default-time="defaultTime"
                              />
                          </el-form-item>
                        </el-form>
                    <template #rightRowFooter>
                      <!-- <el-button type="primary" @click="toImportTempClick" size="large" class="ml-2">
                                  <HcIcon name="folder-upload"/>
                                  <span>上传excel</span>
                      </el-button> -->
                      <HcUploadFile
                            ref="HcUploadFileRef"
                                :options="UploadFileOptions"
                                @progress="HcUploadFileProgress"
                                @success="HcUploadFileSuccess"
                                @change="HcUploadFileChange"
                            >
                               <el-button type="primary"  size="large" class="ml-2">
                                      <HcIcon name="folder-upload"/>
                                      <span>上传excel</span>
                                 </el-button>
                      </HcUploadFile>
                      <el-button type="primary" @click="importModalClose" size="large" class="ml-2">
                                  <HcIcon name="close-circle"/>
                                  <span>取消</span>
                      </el-button>
                    </template>
             </HcDialog>
  </HcCard>
</template>

<script setup>
import {ref, watch} from  'vue'
import dayjs from "dayjs"
import 'dayjs/locale/zh-cn'
import {useRouter} from 'vue-router'
import {getTokenHeader} from "~src/api/request/header";
const router = useRouter()

//下拉日期选择
const datePickerChange = (val) => {
 console.log(val,'val');
 const toDayJs = dayjs(val);
 searchForm.value.month = toDayJs.format('YYYY-MM')

}
const tableColumn = [
    {key: 'name', name: '姓名'},
    {key: 'key2', name: '应出勤天数'},
    {key: 'key4', name: '实际出勤天数'},
    {key: 'key5', name: '年假'},
    {key: 'key6', name: '调休假'},
    {key: 'key7', name: '病假'},
    {key: 'key8', name: '事假'},
    {key: 'key9', name: '基本工资'},
    {key: 'key10', name: '岗位工资'},
    {key: 'key11', name: '绩效工资'},
    {key: 'key12', name: '奖励'},
    {key: 'key13', name: '伙食补贴'},
    {key: 'key14', name: '其他补贴'},
    {key: 'key15', name: '考勤扣款'},
    {key: 'key16', name: '事假扣款'},
    {key: 'key17', name: '其他扣款'},
    {key: 'key18', name: '应发工资'},
    {key: 'key19', name: '代扣个人应交社保'},
    {key: 'key20', name: '代扣代缴个税'},
    {key: 'key21', name: '实发工资'},
    {key: 'key22', name: '备注'},


]
const tableData = ref([
    {name: '名称1',id:1},
    {name: '名称2', },
    {name: '名称3', }
])
const searchForm = ref({
    name: '',
    current: 1, size: 20, total: 0
})
const peopleoption=ref([
    {name: '张三', key: '1'},
    {name: '李四', key: '2'},
])
//分页被点击
const pageChange = ({current, size}) => {
    searchForm.value.current = current
    searchForm.value.size = size
    getTableData()
}

const getTableData = () => {

}

//搜索
const searchClick = () => {
    searchForm.value.current = 1;
    getTableData()
}

//重置搜索表单
const resetClick = () => {
    searchForm.value = {current: 1, size: 20, total: 0}
}
const defaultTime = ref([
  new Date(2000, 1, 1, 0, 0, 0),
  new Date(2000, 2, 1, 23, 59, 59),
])
//导入数据弹窗
const importModal=ref(false)
const importModalClose=()=>{
  importModal.value=false
}
const formModel=ref({})
//下载模板
const downloadXlsx=()=>{

}
const toImportTempClick=()=>{
  importModal.value=true

}
//上传配置
const UploadFileOptions = {
    //此处设置header
    headers: getTokenHeader(),
}

// 文件上传进度
const HcUploadFileProgress = (res) => {
    console.log('文件上传进度', res)
}

const HcUploadFileRef=ref(null)
// 文件上传成功的回调
const HcUploadFileSuccess = (res) => {
    HcUploadFileRef.value?.setModalShow(false);
    importModal.value=false
    getTableData()
   
}

// 文件全部上传成功
const HcUploadFileChange = () => {
    console.log('文件全部上传成功')
}
</script>
<style lang='scss' scoped>
</style>