// /**分页查询接口重试日志 */
import request from '@/utils/request'

import { UPCLOUD_RDC_TMS_MAINDATA_SERVICE, UPCLOUD_RDC_TMS_BUSINESS_SERVICE } from '@/config/serviceSettings.js'
const business = UPCLOUD_RDC_TMS_BUSINESS_SERVICE
const serviceName = UPCLOUD_RDC_TMS_MAINDATA_SERVICE

export const mainTableInfoUrl = business + '/waitDelivered/query_shipbill'
export const mainTableNextInfoUrl = business + '/waitDelivered/query_receiver'
export const advancedQueryUrl = business + '/waitDelivered/advanced_query_shipbill'
export const shipbillTableUrl = business + '/waitDelivered/receiver_get_shipbill'

export const goodsTableUrl = business + '/waitDelivered/item_detail'
export const packageTableUrl = business + '/waitDelivered/package_detail'

//运输管理-/送达确认
export const completeArrangeGoods = (_this, data, close) => {
  let confirmLoading = true
  data.shipbillIds = data.shipbillIds.split(',');
  if (data.checkDetails) {
    data.checkDetails=data.checkDetails.join(',');
  }
  return new Promise((resolve) => {
    _this.$confirm({
      title: '是否送达确认?',
      confirmLoading,
      onOk(clear) {
        confirmLoading = true
        return request({
          url: business + '/waitDelivered/delivered_confirm',
          method: 'post',
          data,
        })
          .then((response) => {
            _this.visible = false
            if (response.success) {
              clear()

              _this.clearChildrenTableAll()
              _this.$refs.mainTable.reload()
              _this.$message.success(response.message)
            } else {
              _this.$exception(response)
            }
            setTimeout(() => {
              confirmLoading = false
            }, 1000)
            return resolve(response)
          })
          .catch((response) => {
            _this.visible = false
            confirmLoading = false
          })
      },
    })
  })
}

export const exportUrls = {
  allUrl: business + '/waitDelivered/export_all_shipbill',
  currentUrl: business + '/waitDelivered/export_page_shipbill',
  selectUrl: business + '/waitDelivered/export_select_line_shipbill',
  ids: []

}
export const printUrl = business + '/waitDelivered/print'

// 获取弹窗的商品数据
export const getDialogTableData = (data) => {
  return request({
    url: goodsTableUrl,
    method: 'post',
    data,
  })
}

// 是否显示启运温度
export const showTemperature = (data) => {
  return request({
    url: business + '/shipbill/showTemperature',
    method: 'post',
    data,
  })
}
// 查容器
export const getQueeryContainer = (_this, data) => {
  return request({
    url: business + '/waitDelivered/delivered_container_query',
    method: 'post',
    data,
  })
}