// /**分页查询接口重试日志 */
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 + '/waitForArrangeGoods/queryShipbillTypePage'
export const mainTableNextInfoUrl = business + '/waitForArrangeGoods/queryReceiverTypePage'
export const mainTableAppointmentUrl = business + '/waitForArrangeGoods/queryAppointmentTypePage'
export const advancedQueryUrl = business + '/waitForArrangeGoods/advanced_query_shipbill'


export const shipbillTableUrl = business + '/waitForArrangeGoods/queryShipbill'

export const goodsTableUrl = business + '/waitForArrangeGoods/queryItemDetail'

export const packageTableUrl = business + '/waitForArrangeGoods/queryPackageDetail'
export const startArrangeGoods = (_this, data) => {
  let confirmLoading = true
  return new Promise((resolve) => {
    _this.$confirm({
      title: '是否开始理货?',
      confirmLoading,
      onOk(clear) {
        confirmLoading = true
        return request({
          url: business + '/waitForArrangeGoods/startArrangeGoods',
          method: 'post',
          // headers: {
          //   'Content-Type': 'application/json',
          // },
          data,
        })
          .then((response) => {
            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) => {
            confirmLoading = false
          })
      },
    })
  })
}

//运输管理-待理货控制层/理货完成
export const completeArrangeGoods = (_this, data) => {
  let confirmLoading = true
  return new Promise((resolve) => {
    _this.$confirm({
      title: '是否理货完成?',
      confirmLoading,
      onOk(clear) {
        confirmLoading = true
        return request({
          url: business + '/waitForArrangeGoods/completeArrangeGoods',
          method: 'post',
          // headers: {
          //   'Content-Type': 'application/json',
          // },
          data,
        })
          .then((response) => {
            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) => {
            confirmLoading = false
          })
      },
    })
  })
}


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

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