// /**分页查询接口重试日志 */
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 + '/outsource_track/page'
export const advancedQueryUrl = business + '/outsource_track/advanced_query_shipbill'

export const shipbillTableUrl = business + '/outsource_track/shipbill'
export const goodsTableUrl = business + '/outsource_track/item'
export const packageTableUrl = business + '/outsource_track/package'


//运输管理-/ 正本回单确认 POST
export const confirmSubmit = (_this, data, close) => {
  let confirmLoading = true
  return new Promise((resolve) => {
    _this.$confirm({
      title: '是否正本回单确认?',
      confirmLoading,
      onOk(clear) {
        confirmLoading = true
        return request({
          url: business + '/outsource_track/confirm',
          method: 'post',
          data,
        })
          .then((response) => {
            close()
            _this.visible = false
            if (response.success) {
              clear()
              _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 handoverSubmit = (_this, data, close) => {
  let confirmLoading = true
  return new Promise((resolve) => {
    _this.$confirm({
      title: '是否托运交接?',
      confirmLoading,
      onOk(clear) {
        confirmLoading = true
        return request({
          url: business + '/outsource_track/handover',
          method: 'post',
          data,
        })
          .then((response) => {
            close()
            _this.visible = false
            if (response.success) {
              clear()
              _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 + '/outsource_track/export_all_shipbill',
  currentUrl: business + '/outsource_track/export_page_shipbill',
  selectUrl: business + '/outsource_track/export_select_line_shipbill',
  ids:[]

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