import { axios } from '@/utils/request'
import request from '@/utils/request'
import { UPCLOUD_RDC_TMS_BUSINESS_SERVICE, UPCLOUD_RDC_TMS_BASE_COMMON } from '@/config/serviceSettings.js'
import qs from 'qs'
const serviceName = UPCLOUD_RDC_TMS_BUSINESS_SERVICE

// 主表地址
export const listRemoteUrl = {
  url: serviceName + '/sendcar/sendcar_page',
  method: 'post',
}

// 配载运单地址
export const waybillListRemoteUrl = {
  url: serviceName + '/sendcar/sendcar_page_detail',
  method: 'post',
}

// 商品表地址
export const goodsListRemoteUrl = {
  url: serviceName + '/sendcar/sendcar_item_detail',
  method: 'post',
}

// 包裹表地址
export const packListRemoteUrl = {
  url: serviceName + '/sendcar/sendcar_package_detail',
  method: 'post',
}

// 审核
export const Audit = (data) => {
  return axios.post(serviceName + '/sendcar/sendcar_audit', data)
}

// 反审核
export const undoAudit = (data) => {
  return axios.post(serviceName + '/sendcar/undoAudit', data)
}

// 撤销
export const Revoke = (data) => {
  return axios.post(serviceName + '/sendcar/sendcar_undo', data)
}

// 查询运单明细
export const viewUrl = (data) => {
  return axios.post(serviceName + '/sendcar/sendcar_view_loadingbillid', qs.stringify(data), {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}

// 地图查询
export const sendcar_map_query = (data) => {
  return axios.post(serviceName + '/sendcar/sendcar_map_query', data)
}

// 配载运单添加
export const sendcar_add_detail = (data) => {
  return axios.post(serviceName + '/sendcar/sendcar_add_detail', data)
}

// 配载运单剔除
export const sendcar_delete_detail = (data) => {
  return axios.post(serviceName + '/sendcar/sendcar_delete_detail', data)
}

// 配载运单移动
export const sendcar_mobile_detail = (data) => {
  return axios.post(serviceName + '/sendcar/sendcar_mobile_detail', data)
}

// 修改保存
export const sendcar_update = (data) => {
  return axios.post(serviceName + '/sendcar/sendcar_update', data)
}

// 查看地图
export const mapView = data => {
  return request({
    url: serviceName + '/sendcar/loadingBillMap',
    method: 'post',
    data,
  })
};

// 线路点保存
export const mapSave = data => {
  return request({
    url: serviceName + '/sendcar/saveLoadingBillMapOrder',
    method: 'post',
    data,
  })
};

// 打印
export function printAsn(params) {
  return request({
    url: UPCLOUD_RDC_TMS_BASE_COMMON + '/print/getPrintInfo',
    method: 'post',
    data: params,
  })
}

// 获取点数据
export function site_info(params) {
  return request({
    url: serviceName + '/sendcar/site_info',
    method: 'post',
    data: params,
  })
}

// 小程序
export function wechat(params) {
  return request({
    url: serviceName + '/inTransit/loadingBill/getTrackByLoadingBillId/wechat',
    method: 'post',
    data: params,
  })
}

// 设备轨迹
export function device(params) {
  return request({
    url: serviceName + '/inTransit/loadingBill/getTrackByLoadingBillId/device',
    method: 'post',
    data: params,
  })
}

// 设备直连
export function deviceLink(params) {
  return request({
    url: serviceName + '/inTransit/loadingBill/getTrackByLoadingBillId/deviceLink',
    method: 'post',
    data: params,
  })
}

// 报警地址
export const alertRemoteUrl = {
  url: serviceName + '/inTransit/common/getAlarm/wechat',
  method: 'post',
}