lrj
16 小时以前 7ad9c3c93f0cc103347ae2e2429e0122fb512e24
web/src/api/employee.ts
@@ -19,7 +19,7 @@
    }
  `,
  
  // 根据姓名搜索员工
  // 搜索员工
  SEARCH_EMPLOYEES: `
    query SearchEmployees($name: String) {
      employeesByName(name: $name) {
@@ -99,18 +99,18 @@
  // 获取员工列表
  async getEmployees(): Promise<Employee[]> {
    try {
      const data = await graphqlRequest(EMPLOYEE_QUERIES.GET_EMPLOYEES)
      return data?.employees || []
      const result = await graphqlRequest(EMPLOYEE_QUERIES.GET_EMPLOYEES)
      return result?.data?.employees || []
    } catch (error: any) {
      throw new Error(error.message || '获取员工列表失败')
    }
  },
  // 搜索员工
  async searchEmployees(keyword: string): Promise<Employee[]> {
  async searchEmployees(name: string): Promise<Employee[]> {
    try {
      const data = await graphqlRequest(EMPLOYEE_QUERIES.SEARCH_EMPLOYEES, { keyword })
      return data?.searchEmployees || []
      const result = await graphqlRequest(EMPLOYEE_QUERIES.SEARCH_EMPLOYEES, { name })
      return result?.data?.employeesByName || []
    } catch (error: any) {
      throw new Error(error.message || '搜索员工失败')
    }
@@ -119,8 +119,8 @@
  // 根据ID获取员工详情
  async getEmployee(id: string): Promise<Employee | null> {
    try {
      const data = await graphqlRequest(EMPLOYEE_QUERIES.GET_EMPLOYEE, { id })
      return data?.employee || null
      const result = await graphqlRequest(EMPLOYEE_QUERIES.GET_EMPLOYEE, { id })
      return result?.data?.employee || null
    } catch (error: any) {
      throw new Error(error.message || '获取员工详情失败')
    }
@@ -129,8 +129,8 @@
  // 保存员工(新增或更新)
  async saveEmployee(employee: EmployeeInput): Promise<Employee> {
    try {
      const data = await graphqlRequest(EMPLOYEE_MUTATIONS.SAVE_EMPLOYEE, { input: employee })
      return data?.saveEmployee
      const result = await graphqlRequest(EMPLOYEE_MUTATIONS.SAVE_EMPLOYEE, { input: employee })
      return result?.data?.saveEmployee
    } catch (error: any) {
      throw new Error(error.message || '保存员工失败')
    }
@@ -139,8 +139,8 @@
  // 删除员工
  async deleteEmployee(id: string): Promise<boolean> {
    try {
      const data = await graphqlRequest(EMPLOYEE_MUTATIONS.DELETE_EMPLOYEE, { id })
      return data?.deleteEmployee || false
      const result = await graphqlRequest(EMPLOYEE_MUTATIONS.DELETE_EMPLOYEE, { id })
      return result?.data?.deleteEmployee || false
    } catch (error: any) {
      throw new Error(error.message || '删除员工失败')
    }