employee.ts 1.65 KB
import { RpcApiClient } from '../core/rpc-client';
import type { EmployeeRow, RpcListResult } from '../core/types';

/** 员工管理接口。method 与参数名逐字保留老 H5(html/employee/*.html)。 */
class EmployeeApi extends RpcApiClient {
  findStaffByPage(params: Record<string, unknown> = {}) {
    return this.rpc<RpcListResult<EmployeeRow>>(
      'entmicro-account',
      'merchants.api.staff.findStaffByPage',
      params,
    );
  }

  staffSearchRequest(id: string | number) {
    return this.rpc<EmployeeRow>('entmicro-account', 'merchants.api.staff.staffSearchRequest', {
      id,
    });
  }

  saveStaff(params: Record<string, unknown>) {
    return this.rpc<unknown>('entmicro-account', 'merchants.api.staff.saveStaff', params);
  }

  updateStaff(params: Record<string, unknown>) {
    return this.rpc<unknown>('entmicro-account', 'merchants.api.staff.updateStaff', params);
  }

  deleteStaff(id: string | number) {
    return this.rpc<unknown>('entmicro-account', 'merchants.api.staff.deleteStaff', { id });
  }

  updateStatus(params: Record<string, unknown>) {
    return this.rpc<unknown>('entmicro-account', 'merchants.api.staff.updateStatus', params);
  }

  updateValPerByStaffId(params: Record<string, unknown>) {
    return this.rpc<unknown>(
      'entmicro-account',
      'merchants.api.staff.updateValPerByStaffId',
      params,
    );
  }

  /** 返回后端给出的文件地址;页面必须交给 downloadCenter.url 登记,禁止 window.open。 */
  exportData(params: Record<string, unknown>) {
    return this.rpc<string>('entmicro-account', 'merchants.api.staff.exportData', params);
  }
}

export const employeeApi = new EmployeeApi();