import request from '@/utils/http'

// 合同查询参数类型
export interface ContractQueryParams {
  page?: number
  pageSize?: number
  code?: string
  customer?: string
  contractStatus?: string
  type?: string
  signDate?: string
  paymentDate?: string
  performanceDeadline?: string
  salespersonId?: string
  departmentId?: string
  projectId?: string
}

// 合同响应数据类型
export interface ContractData {
  accountNumber: string
  amount: number
  code: string
  contractId: string
  contractStatus: string
  contractText: string
  customer: string
  departmentId: string
  duration: string
  notes: string
  page: number
  pageSize: number
  paymentAddress: string
  paymentDate: string
  performanceDeadline: string
  productService: string
  projectId: string
  projectName: string
  receivedAmount: number
  salespersonDeptName: string
  salespersonId: string
  salespersonName: string
  settlementAmount: number
  signDate: string
  type: string
}

// 合同列表响应类型
export interface ContractListResponse {
  code: number
  msg: string
  rows: ContractData[]
  total: number
}

const BASE_URL = '/contract'

/**
 * 获取合同列表
 * @param params 查询参数
 */
export function getContractList(params: ContractQueryParams) {
  return request.get<ContractListResponse>(`${BASE_URL}/list`, params)
}
