import request from '@/utils/data_request'
import {
	usertoken
} from '../config'
import {
	parseXML,
	parseEncodedData
} from '@/utils/transUtil.js'
//获取【生产组织】
export function getOrg() {
	const data = {
		usertoken: usertoken,
		searchType: 'org'
	}
	// const urlEncodedData = Object.keys(data)
	// 	.map(key => encodeURIComponent(key) + '=' + encodeURIComponent(data[key]))
	// 	.join('&');
	// console.log(urlEncodedData)
	return request({
		'url': '/services/LUTAIWebService.asmx/GetClothesEnchaseBaseData',
		'method': 'post',
		'data': data
	})
}

//获取【生产车间】
export function getDept() {
	const data = {
		usertoken: usertoken,
		searchType: 'dept'
	}
	return request({
		'url': '/services/LUTAIWebService.asmx/GetClothesEnchaseBaseData',
		'method': 'post',
		'data': data
	})
}

//获取【装箱方式】
export function getenchasetype() {
	const data = {
		usertoken: usertoken,
		searchType: 'enchasetype'
	}
	return request({
		'url': '/services/LUTAIWebService.asmx/GetClothesEnchaseBaseData',
		'method': 'post',
		'data': data
	})
}

//根据箱号Id(二维码)获取装箱明细信息
export function GetClothesEnchaseByQRCode(data) {
	const param = {
		usertoken: usertoken,
		QRCode: data
	}
	console.log(param)
	return request({
		'url': '/services/LUTAIWebService.asmx/GetClothesEnchaseByQRCode',
		'method': 'post',
		'data': param
	})
}

//根据成衣条码(唯一码)获取唯一码信息
// export function GetClothesEnchaseByBarCode(data) {
// 	const param = {
// 		usertoken: usertoken,
// 		BarCode: data
// 	}
// 	return request({
// 		'url': '/services/LUTAIWebService.asmx/GetClothesEnchaseByBarCode',
// 		'method': 'post',
// 		'data': param
// 	})
// }

//根据成衣条码(唯一码)与订单号获取成衣信息
export function GetClothesEnchaseByBarCode(barCode, orderNo = null) {
	let param = ''
	if (orderNo !== null) {
		param = {
			usertoken: usertoken,
			BarCode: barCode,
			orderNo: orderNo
		}
	} else {
		param = {
			usertoken: usertoken,
			BarCode: barCode,
			orderNo:''
		}
	}

	return request({
		'url': '/services/LUTAIWebService.asmx/GetClothesEnchaseByBarCode',
		'method': 'post',
		'data': param
	})
}

//生成装箱校验
export function GenerateClothesEnchaseCheck(data) {
	// let encodeParam = parseEncodedData(data)
	const param = {
		usertoken: usertoken,
		jsonData: data
	}

	return request({
		'url': '/services/LUTAIWebService.asmx/GenerateClothesEnchaseCheck',
		'method': 'post',
		'data': param
	})
}

//生成装箱
export function GenerateClothesEnchase(data) {
	// let encodeParam = parseEncodedData(data)
	const param = {
		usertoken: usertoken,
		jsonData: data
	}

	return request({
		'url': '/services/LUTAIWebService.asmx/GenerateClothesEnchase',
		'method': 'post',
		'data': param
	})
}