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

import { UPCLOUD_RDC_TMS_BMS_SERVICE, UPCLOUD_RDC_TMS_MAINDATA_SERVICE, UPCLOUD_RDC_TMS_BUSINESS_SERVICE } from '@/config/serviceSettings.js'

const bms = UPCLOUD_RDC_TMS_BMS_SERVICE

///BMS-收入台账管理/台账运单列表查询
export const mainTableInfoUrl = bms + '/arReconciliationMng/findLoadingBillFee'


//运单详情
export const mainViewUrl = bms + '/arReconciliationMng/detailLoadingBillById'



//跟据派车单查运单明细
export const childrenShipBillTableUrl = bms + '/arReconciliationMng/getShipBill'

//运单商品明细查询
export const childrenTableInfoUrl = bms + '/arReconciliationMng/getItem'

//包裹信息
export const packTableInfoUrl = bms + '/arReconciliationMng/getPackage'
//日志
export const logTableInfoUrl = bms + '/arReconciliationMng/getLog'

//费用
export const adjustTableInfoUrl = bms + '/arReconciliationMng/getDetail'
// 审批信息查询 POST
export const auditTableInfoUrl = bms + '/driverledgerBill/listAudit'

//批量导入
export const mainDownUrl = bms + '/arReconciliationMng/download_template'
export const mainImportUrl = bms + '/arReconciliationMng/import'



function responseThen(response) {
  if (response.success) {
    this.visible = false
    this.$message.success(response.message)
  } else {
    this.$exception(response)
  }
  setTimeout(() => {
    this.confirmLoading = false
  }, 1000)
  return response
}


//运单提交
export const dataSubmit = (_this, data) => {

  let confirmLoading = true
  return new Promise((resolve) => {
    _this.$confirm({
      title: '是否提交运单费用' + '?',
      confirmLoading,
      onOk(clear) {
        confirmLoading = true
        return request({
          url: bms + '/shipBill/feeSubmit/v1.0',
          method: 'post',
          data,
        })
          .then((response) => {
            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) => {
            confirmLoading = false
          })
      },
    })
  })
}
//费用提交
export const dataFeeSubmit = (_this, data) => {

  let confirmLoading = true
  return new Promise((resolve) => {
    _this.$confirm({
      title: '是否提交费用' + '?',
      confirmLoading,
      onOk(clear) {
        confirmLoading = true
        return request({
          url: bms + '/shipBill/feeInfoSubmit/v1.0',
          method: 'post',
          data,
        })
          .then((response) => {
            if (response.success) {
              clear()
              _this.childrenTableReload()
              _this.$message.success(response.message)
            } else {
              _this.$exception(response)
            }
            setTimeout(() => {
              confirmLoading = false
            }, 1000)
            return resolve(response)
          })
          .catch((response) => {
            confirmLoading = false
          })
      },
    })
  })
}


//费用提交
export const itemConfirm = (_this, data) => {
  let confirmLoading = true
  return new Promise((resolve) => {
    _this.$confirm({
      title: '是否确认对账单' + '?',
      confirmLoading,
      onOk(clear) {
        confirmLoading = true
        return request({
          url: bms + '/arReconciliationMng/confirm',
          method: 'post',
          data,
        })
          .then((response) => {
            if (response.success) {
              clear()
              _this.$refs.mainTable.reload();
              _this.childrenTableReload()
              _this.$message.success(response.message)
            } else {
              _this.$exception(response)
            }
            setTimeout(() => {
              confirmLoading = false
            }, 1000)
            return resolve(response)
          })
          .catch((response) => {
            confirmLoading = false
          })
      },
    })
  })
}


