// /**分页查询接口重试日志 */
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
// 待排计划单分页查询 POST
export const mainTableInfoUrl = business + '/transport_plan_bill/pending_plan_page'



//点运单修改查询的接口
export const mainViewUrl = business + '/shipbill/view_id'
// /allShipbill/adjust


export const exportUrls = {
  allUrl: business + '/allShipbill/export',
  currentUrl: business + '/allShipbill/exportPage',
  selectUrl: business + '/allShipbill/exportSelected',
  ids:[]

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


//订单修改 保存
export const mainSaveData = (_this, data) => {
  let url = business + '/allShipbill/adjust'
  let title='是否保存订单商品?'
  if (_this.title === '关闭运单') {
    url = business + '/allShipbill/close';
    title = '是否关闭运单';
  }

  let confirmLoading = true
  return new Promise((resolve) => {
    _this.$confirm({
      title,
      confirmLoading,
      onOk(clear) {
        confirmLoading = true
        _this.load = true
        return request({
          url,
          method: 'post',
          data,
        }) .then((response) => {
          if (response.success) {
            clear()
            _this.$message.success(response.message)
          } else {
            _this.$exception(response)
          }
          _this.load = false
          confirmLoading = false
          return resolve(response)
        })
          .catch((response) => {
            confirmLoading = false
         })

      },
    })
  })
}

//关联运单
export const getTreeShipbill = (_this, data) => {
  const { originalShipbillId,shipbillId}=data
  _this.visible = true
  return request({
    url: business + '/allShipbill/related_shipbill',
    method: 'post',
    data:{
      originalShipbillId:originalShipbillId||shipbillId,
      shipbillId
    },
  })
    .then((response,reject) => {
      if (response.success) {
        // _this.$message.success(response.message)
      } else {
        _this.$exception(response)
      }
      return response

    })
    .finally((response) => {
      _this.visible = false

    })
}
