import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace AssetVehicleReplacementApi {
  export interface VehicleReplacement {
    id?: number;
    replacementCode?: string;
    replacementType: number;
    contractId?: number;
    contractCode?: string;
    projectName?: string;
    customerId?: number;
    customerName?: string;
    originalVehicleId?: number;
    originalPlateNo?: string;
    originalVin?: string;
    newVehicleId?: number;
    newPlateNo?: string;
    newVin?: string;
    deliveryOrderId?: number;
    replacementReason?: string;
    expectedDate?: string;
    actualDate?: string;
    returnDate?: string;
    status?: number;
    approvalStatus?: number;
    bpmInstanceId?: string;
    remark?: string;
    creator?: string;
    createTime?: Date;
  }
}

export function getVehicleReplacementPage(params: PageParam) {
  return requestClient.get<
    PageResult<AssetVehicleReplacementApi.VehicleReplacement>
  >('/asset/vehicle-replacement/page', { params });
}

export function getVehicleReplacement(id: number) {
  return requestClient.get<AssetVehicleReplacementApi.VehicleReplacement>(
    `/asset/vehicle-replacement/get?id=${id}`,
  );
}

export function createVehicleReplacement(
  data: AssetVehicleReplacementApi.VehicleReplacement,
) {
  return requestClient.post('/asset/vehicle-replacement/create', data);
}

export function updateVehicleReplacement(
  data: AssetVehicleReplacementApi.VehicleReplacement,
) {
  return requestClient.put('/asset/vehicle-replacement/update', data);
}

export function deleteVehicleReplacement(id: number) {
  return requestClient.delete(`/asset/vehicle-replacement/delete?id=${id}`);
}

export function submitVehicleReplacementApproval(id: number) {
  return requestClient.post(
    `/asset/vehicle-replacement/submit-approval?id=${id}`,
    {},
  );
}

export function withdrawVehicleReplacementApproval(id: number) {
  return requestClient.post(
    `/asset/vehicle-replacement/withdraw-approval?id=${id}`,
    {},
  );
}

export function confirmVehicleReplacementReturn(id: number) {
  return requestClient.post(
    `/asset/vehicle-replacement/confirm-return?id=${id}`,
    {},
  );
}
