/**
 * 工作台列表接口
 */
import { request } from '../../utils/request'
import type { WorkItem, WorkListParams, PageResult, ContractorListResponse } from '../../types/workbench'

/**
 * 获取工作台列表
 */
export const getWorkList = (params: WorkListParams): Promise<PageResult<WorkItem>> => {
    return request<PageResult<WorkItem>>({
        url: '/api/workbench/list',
        method: 'GET',
        data: params as any as UTSJSONObject
    })
}

/**
 * 获取承包商列表
 * @param page 页码
 * @param rows 每页数量
 * @param contractorName 承包商名称（可选）
 */
export const getContractorList = (page: number, rows: number, contractorName: string | null): Promise<any> => {
    let url = `/infoThirdParty/getByPage?page=${page}&rows=${rows}`
    if (contractorName != null && contractorName.length > 0) {
        url += `&contractorName=${contractorName}`
    }
    return request({
        url: url,
        method: 'GET'
    })
}

/**
 * 获取承包商列表
 * @param page 页码
 * @param rows 每页数量
 * @param workOrderProjectNo 工单编码（可选）
 */
export const getOrderList = (page: number, rows: number, workOrderProjectNo: string | null): Promise<any> => {
    let url = `/mobile/order/list?pageNum=${page}&pageSize=${rows}`
    if (workOrderProjectNo != null && workOrderProjectNo.length > 0) {
        url += `&repairOrder.workOrderProjectNo=${workOrderProjectNo}`
		url += `&workOrder.workOrderProjectNo=${workOrderProjectNo}`
    }
    return request({
        url: url,
        method: 'GET'
    })
}
