import Request from "./request";
import uploadFile from "./uploadFile";
import downloadFile from "./downloadFile";

// 用户登录
export function userLogin(loginAction, loginCode, data) {
  return Request(
    `/api/auth/app-login/{mini}/${loginAction}?weixin_config_key={mini}&code=${loginCode}`,
    data
  );
}

//获取是否添加水印字段
export function getWaterMark() {
  return Request(`/api/user`, {}, "GET");
}

// 用户中心操作&&初始化JS-SDK  action 说明： 退出登录：logout  获取用户信息: getUserInfo 初始化SDK: querySignature
export function userMobileOperation(action, data) {
  if (action === "logout") {
    //退出登录
    return Request(`/logout`, data, "GET"); // data: {openId, entryName}
  } else {
    return Request(`/api/entry/{mini}/m-action/${action}`, data);
  }
}
//获取地图key
export function getMap() {
  return Request(`/api/query/*/action/getMap`);
}
//获取地图颜色
export function getMapColor(data) {
  return Request(`/api/query/biz.md.Truck/action/service-getMapColor`, data);
}
// 上传图片
export function uploadImg(data, fileType = "image") {
  return uploadFile("/api/doc/upload", data, fileType);
}
// 下载图片
export function downloadImg(data) {
  return downloadFile("/api/doc/download", data);
}
// 下载文件
export function DownloadFile(data) {
  return downloadFile("/api/doc/download", data, {}, false);
}
// 获取文件名
export function findFileName(filePath) {
  return Request(`/api/doc/download/${filePath}`, {}, "GET", {}, false);
}
//获取选项枚举
//type说明： 上报类型：TransitType 费用类型：DriverCostType 订单上报类型：OrderEventType
export function getOptionEnum(type) {
  return Request(`/api/query/choice.tm.${type}/action/auto_choice`);
}

//监听实时位置
export function updateLocation(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.md.Facility.service.send`,
    data,
    "POST",
    {},
    false
  );
}

// 运单部分
//开始运输
export function startShipment(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.Shipment.operation.start`,
    data
  );
}
//查询运单列表 state说明：已完成：finished  未完成：unfinished
export function shipmentOrder(state, data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.Shipment.tm_shipment_m_driver_${state}.paging`,
    data
  );
}
//运单详情
export function shipmentOrderDetail(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.Shipment.tm_shipment_m_driver_page.get`,
    data
  );
}

//大宗模式查询运单详情
export function shipmentOrderDetailMass(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.MassShipment.tm_massshipment_m_driver_page.get`,
    data
  );
}

//查询运单途径站点
export function shipmentStationDetail(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ShipmentStop.tm_shipmentstop_m_driver.paging`,
    data
  );
}
//订单列表 OM/OR/MASS模式
export function ordermovementOM(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.OrderMovement.tm_ordermovement_m_search.paging`,
    data
  );
}
export function ordermovementOR(data) {
  //tm_simpleorder_m_search
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.SimpleOrder.tm_simpleorder_shipment_m_search.paging`,
    data
  );
}
export function ordermovementMASS(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.MassShipment.tm_massshipment_m_page.get`,
    data
  );
}

// 查询订单明细
// OM模式
export function OMOrderDetail(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.OrderMovementLine.tm_ordermovementline_m_search.paging`,
    data
  );
}
// OR模式
export function OROrderDetail(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.OrderLine.tm_orderline_m_search.paging`,
    data
  );
}
// OR模式
export function OROrderReleaseDetail(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.OrderRelease.tm_orderrelease_m_search.paging`,
    data
  );
}
//操作历史
export function operationHistory(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ShipmentEvent.tm_shipmentevent_m_search.paging`,
    data
  );
}
//操作详情
export function operationDetail(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ShipmentEvent.tm_shipmentevent_m_page.get`,
    data
  );
}
//查询中转地址
export function searchTransferAddress(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.md.TransferAddress.md_transferaddress_m_search.paging`,
    data
  );
}

//上报 & 中转换车
//action说明：上报：sign 费用上报：expenseReport 中转换车：transferAndChangeTruck 中转卸货：transferAndUnload
export function reportInfo(action, data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.Shipment.operation.${action}`,
    data
  );
}
//费用上报
export function reportDriverCost(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.Shipment.service.reportDriverCost`,
    data
  );
}

//上报订单
export function reportOrder(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.OrderRelease.operation.sign`,
    data
  );
}

// 运单操作
//action说明： 已配载：扫码装货：scanOrderLoad  扫码卸货：scanOrderUnload  未配载：扫码装货：scanOrderShipLoad  扫码卸货：scanOrderShipUnload 数量装货：loadQty 数量卸货：unloadQty 重量装货：loadWeight  重量卸货：unloadWeight
export function shipmentStop(action, data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ShipmentStop.operation.${action}`,
    data
  );
}
//action说明：到站：arrival 离站：departure  上传磅单：uploadWeight 开始装货：loading 装货完成：loadFinish 移除装货：loadRemove 放弃装货：loadAbort 开始卸货：unloading 卸货完成：unloadFinish 拒绝卸货：unloadRefuse 电子签名：signature
export function shipmentLocation(action, data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ShipmentLocation.operation.${action}`,
    data
  );
}

//action说明： getLoadedData 扫码装 getUnloadedData 扫码卸
export function getLocationLoade(action, data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ShipmentLocation.service.${action}`,
    data
  );
}

//装卸货取消
//OM模式 action说明: 装货取消 loadCancel 卸货取消 unloadCancel
export function OMShipmentCancel(action, data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.OrderMovement.operation.${action}`,
    data
  );
}
//OR模式 action说明: 装货取消  loadCancel 卸货取消 unloadCancel
export function ORShipmentCancel(action, data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.SimpleOrder.operation.${action}`,
    data
  );
}

//签收  模式：OM：MovementShipment  OR: SimpleShipment MS: MassShipment(大宗运输)
export function signFor(shipMode, data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.${shipMode}.service.receive`,
    data
  );
}

// //回单上传  模式：OM：OrderMovement  OR: SimpleOrder
// export function uploadReceive(shipMode, data) {
//   return Request(`/api/entry/{mini}/m-action/biz.tm.${shipMode}.operation.receive`, data)
// }

// 接单列表
export function findAcceptOrders(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.MassOrderTruck.tm_massordertruck_m_accept.paging`,
    data
  );
}

// 司机接单
export function CreateShipment(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.MassOrderTruck.operation.createShipment`,
    data
  );
}

// 获取排队预约单列表
export function QuerySubscribeList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.TruckQueueAccess.tm_truckqueueaccess_m_search.paging`,
    data
  );
}

// 获取排队预约单列表
export function QueryLazySubscribeList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.LazyTruckQueueAccess.tm_lazytruckqueueaccess_m_search.paging`,
    data
  );
}

// 获取排队交货单列表
export function QueryDeliveryTruckList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.DeliveryTruck.tm_deliverytruck_m_search.paging`,
    data
  );
}

// 获取排队交货单生成预约单
export function CreatSubscribeArrowDelivery(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.DeliveryTruck.operation.createAccess`,
    data
  );
}

// 获取预约单物料明细
export function QueryAccessItemList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.TruckAccessItem.tm_truckaccessitem_m_search.paging`,
    data
  );
}

// 获取道口预约时间列表
export function GetDockOrderTimeList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.md.DockTimeTable.md_docktimetable_m_search.paging`,
    data
  );
}

// 预约单预约
export function SubscribeFormSubmit(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.TruckQueueAccess.operation.appoint`,
    data
  );
}

// 预约单预约
export function NewSubscribeFormSubmit(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.TruckQueueAccess.operation.appointConditional`,
    data
  );
}

// 预约单签到
export function SubscribeFormSign(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.TruckQueueAccess.operation.sign`,
    data
  );
}

// 获取排队月台信息
export function GetDockInfo(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.md.Dock.md_dock_m_page.get`,
    data
  );
}

// 获取排队预约单详情
export function GetOrderDetail(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.TruckQueueAccess.tm_truckqueueaccess_m_page.get`,
    data
  );
}

// 获取物料对应月台
export function GetProductDockList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ProductDockRule.tm_productdockrule_m_search.paging`,
    data
  );
}

// 获取可预约天数
export function GetOrderDays(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.md.Address.md_address_releation_page.get`,
    data
  );
}

// 获取预约单操作历史
export function GetOrderHistoryEvent(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.TruckAccessEvent.tm_truckaccessevent_trace_m_relation.paging`,
    data
  );
}

// 确认运单
export function ApproveShipment(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.Shipment.operation.approve`,
    data
  );
}
// 获取司机考试试卷
export function GetDriverExamPaper(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ExamPaper.tm_exampaper_m_search.paging`,
    data
  );
}

// 获取司机全部考试结果
export function GetDriverExamResult(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ExamInstance.tm_examinstance_m_search.paging`,
    data
  );
}

// 获取试卷信息
export function GetDriverExamItem(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ExamPaper.tm_exampaper_m_page.get`,
    data
  );
}

// 获取试卷考题信息
export function GetDriverExamItemInfo(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ExamItem.tm_examitem_m_page.get`,
    data
  );
}

// 提交试卷结果
export function ReportExamPaperResult(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ExamPaper.service.submitPaper`,
    data
  );
}

// 获取司机详细考试结果
export function GetDriverExamPaperResult(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ExamInstance.tm_examinstance_m_page.get`,
    data
  );
}

// 下载视频
export function downloadVideo(data) {
  return downloadFile("/api/doc/download", data);
}

// 获取车辆检查项目
export function GetTruckCheckItems(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.TruckCheckItem.tm_truckcheckitem_m_search.paging`,
    data
  );
}

// 获取车辆检查项目明细
export function GetTruckCheckItemList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.TruckCheckItemLine.tm_truckcheckitemline_m_search.paging`,
    data
  );
}

// 提交车辆点检结果
export function SubmitTruckCheckItemResult(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.TruckDailyCheck.service.truckCheck`,
    data
  );
}

//获取运单报销列表
export function GetShipmentExpenseList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ShipmentExpense.tm_shipmentexpense_m_search.paging`,
    data
  );
}

// 获取运单报销详情
export function GetShipmentExpenseInfo(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ShipmentExpense.tm_shipmentexpense_m_page.get`,
    data
  );
}

//获取司机报销列表
export function GetDriverExpenseList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.DriverCost.tm_drivercost_search.paging`,
    data
  );
}

// 获取司机报销详情
export function GetDriverExpenseInfo(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.DriverCost.tm_drivercost_m_page.get`,
    data
  );
}

//获取司机报销单列表
export function GetDriverExpensReceiptList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.DriverReimbursement.tm_driverreimbursement_search.paging`,
    data
  );
}

// 获取司机报销单详情
export function GetDriverExpenseReceiptInfo(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.DriverReimbursement.tm_driverreimbursement_page.get`,
    data
  );
}

//获取司机报销单报销事件
export function GetDriverExpenseReceiptEventList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.DriverReimbursementEvent.tm_driverreimbursementevent_search.paging`,
    data
  );
}

//获取司机报销单报销列表
export function GetDriverExpensReceiptExpensList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.DriverCost.tm_drivercost_reimbursement_detail_search.paging`,
    data
  );
}

// 提交试卷结果
export function GetReserveExamResult(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ExamPaper.service.getExamInstance`,
    data
  );
}

// 提交试卷结果
export function GetReserveListExamResults(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ExamPaper.service.getExamInstanceMap`,
    data
  );
}

//获取司机列表
export function GetDriverList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.md.Driver.md_driver_m_search.paging`,
    data
  );
}

// 预约单地址获取
export function GetTruckAccessAddressByDriverTel(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ExamPaper.service.getTruckAccessAddressByDriverTel`,
    data
  );
}

// 预约单预约
export function ExecuteNewAccess(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.TruckQueueAccess.operation.executeNewAccess`,
    data
  );
}

// 验证码发送
export function SendMessage(data) {
  return Request(`/handler/sendMessage`, data);
}

// 订单轨迹
export function findShipmentLbs(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.Shipment.service.lbs`,
    data
  );
}

// 获取物料对应月台列表
export function GetCargoDockList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.ProductDockRule.tm_productdockrule_m_search.paging`,
    data
  );
}

// 获取月台列表
export function GetMiniDockList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.md.Dock.md_dock_m_search.paging`,
    data
  );
}

// 获取拜访单
export function getVisitOrder(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.TruckVisitAccess.tm_truckvisitaccess_m_search.paging`,
    data
  );
}
// 获取拜访单详情
export function getVisitOrderDetails(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.TruckVisitAccess.tm_truckvisitaccess_m_search.get`,
    data
  );
}

export function getVisitOrderHistoryEvent(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.TruckVisitAccess.tm_truckvisitaccess_m_search.paging`,
    data
  );
}

// 获取部门
export function getDepartment(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.md.Organization.md_organization_m_search.paging`,
    data
  );
}

// 新增拜访单
export function addVisitOrder(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.TruckVisitAccess.bizInsert`,
    data
  );
}

//获取地址
export function getAddressList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.md.Address.md_address_search.paging`,
    data
  );
}

// 获取排队预约单客户列表
export function QueryLazySubscribeOwnerList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.LazyTruckAccessOwner.tm_lazytruckaccessowner_search.paging`,
    data
  );
}

export function ChangeCargoWork(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.LazyTruckAccessOwner.service.resetWorkNumber`,
    data
  );
}

// 获取排队预约单去向列表
export function QueryLazySubscribeGoneList(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.LazyTruckAccessDock.tm_lazytruckaccessdock_relation.paging`,
    data
  );
}

// 是否存在相同去向
export function IsNextHasSameDock(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.LazyTruckQueueAccess.operation.isNextHasSameDock`,
    data
  );
}

// 普通完成
export function EndWork(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.LazyTruckQueueAccess.operation.end`,
    data
  );
}

// 相同去向一起完成
export function EndWithSameDock(data) {
  return Request(
    `/api/entry/{mini}/m-action/biz.tm.LazyTruckQueueAccess.operation.endWithSameDock`,
    data
  );
}

//首页-获取公告
export function getBulletin(data){
	return Request(`/api/entry/{mini}/m-action/biz.system.Notification.service.getBulletin`,data)
}

//提交建议
export function addSuggestions(data){
	return Request(`/api/entry/{mini}/m-action/biz.wlj.ComplaintsAndSuggestions.service.getBulletin`,data)
}


// 查询运单
export function getShipmentByAction(data) {
	return Request(`/api/entry/{mini}/m-action/biz.tm.Shipment.service.getShipmentByAction`, data)
}

// 查询运单
export function getShipmentList(data) {
	return Request(`/api/entry/{mini}/m-action/biz.tm.Shipment.tm_shipment_m_driver.paging`, data)
}


// 上传回单
export function podUpload(data) {
	return Request(`/api/entry/{mini}/m-action/biz.tm.Shipment.service.podUpload`, data)
}	

// 在途打卡
export function punchIn(data) {
	return Request(`/api/entry/{mini}/m-action/biz.tm.Shipment.service.punchIn`, data)
}	