<template>
  <div>
    <el-form :model="searchForm" inline>
      <el-form-item>
        <el-input v-model="searchForm.name" placeholder="请输入员工姓名" />
      </el-form-item>
      <el-form-item>
        <el-radio-group v-model="searchForm.status">
          <el-radio :label="0"> 在职 </el-radio>
          <el-radio :label="1"> 离职 </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <el-button @click="handleQuery">搜索</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="tableList" border stripe>
      <el-table-column type="index" width="50" />
      <el-table-column label="用户姓名" prop="nickname" />
      <el-table-column label="部门" key="deptName" prop="deptName" />
      <el-table-column label="手机号码" prop="mobile" width="120" />
      <el-table-column label="在职状态" prop="status" />
      <el-table-column label="操作">
        <template #default="scope">
          <el-button type="primary" link @click="openForm(scope.row)"> 工资条设置 </el-button>
        </template>
      </el-table-column>
    </el-table>
    <Pagination
      :total="total"
      v-model:page="searchForm.pageNo"
      v-model:limit="searchForm.pageSize"
      @pagination="getList"
    />
    <DialogSalary ref="salaryDialogRef" @success="getList" />
  </div>
</template>

<script name="EmployeeList" setup>
import DialogSalary from './Comp/DialogSalary.vue'
const searchForm = ref({
  name: undefined,
  status: 0,
  pageNo: 1,
  pageSize: 20
})

onMounted(() => {
  handleQuery()
})

/** 搜索按钮操作 */
const handleQuery = () => {
  searchForm.value.pageNo = 1
  getList()
}

const loading = ref(false)
const tableList = ref([])
const total = ref(0)
/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    tableList.value = [1, 2]
    // const data = await UserApi.getUserPage(queryParams)
    // tableList.value = data.list
    // total.value = data.total
  } finally {
    loading.value = false
  }
}

const salaryDialogRef = ref()
function openForm(row) {
  salaryDialogRef.value.open(row)
}
</script>

<style lang="scss" scoped></style>
