
<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="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="warning" @click="toImportTempClick" size="large">
          <HcIcon name="delete-bin-2"/>
                    <span>草稿箱</span>
         </el-button>
         <el-button type="primary" size="large" class="ml-2" @click="addinfoClick">
                    <HcIcon name="add"/>
                    <span>新增出差申请</span>
         </el-button>
    </template>
    <HcTable :column="tableColumn" :datas="tableData" >
      <template #action="{row, index}">
         <el-button hc-btn type="primary" size="small">撤销</el-button>
       </template>
      </HcTable>
      <template #action>
            <HcPages :pages="searchForm" @change="pageChange"></HcPages>
      </template>
            <!--草稿箱弹窗-->
            <HcDialog bgColor="#ffffff" widths="62rem" isToBody  :show="importModal" title="草稿箱" @close="importModalClose" isTable >
              <el-alert title="3个月内未更新的草稿将被自动删除" type="warning"  show-icon/>
              <div class="table_box">
                <HcTable :column="drafttableColumn" :datas="drafttableData" ui="hc-test-drop-table" isRowDrop isSort @row-drop="rowDropTap" @row-sort="rowSortTap">
                  <template #action="{row, index}">
                    <el-button hc-btn type="primary" size="small" @click="editinfoClick(row)">继续编辑</el-button>
                    <el-button hc-btn type="primary" size="small">删除</el-button>
                  </template>
                </HcTable>
              </div>
               
             </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 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: 'action', name: '操作',widths:100},


]
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 drafttableColumn = [
    {key: 'name', name: '标题'},
    {key: 'text', name: '更新时间'},
    {key: 'action', name: '操作',widths:120},
]
const drafttableData = ref([
    {name: '名称1', text: '2023-5-23 15:21:08', },
    {name: '名称1', text: '2023-5-23 15:21:08', },
    
 
])

// 行拖拽
const rowDropTap = (rows) => {
    tableData.value = rows
}

// 点击排序
const rowSortTap = (rows) => {
    tableData.value = rows
}

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

}
//编辑出差申请
const addinfoClick=()=>{
  router.push({
        name: 'attendance-business-trip-info',
        query: {
            type: 'add'
        }
    })
}
const editinfoClick=(row)=>{
  importModal.value=false
  router.push({
        name: 'attendance-business-trip-info',
        query: {
            type: 'edit'
        }
    })
}
</script>
<style lang='scss' scoped>
</style>