let partsApiFun = function (vm) {
	// 接口公共前缀
	const prefix = '/wxh-worker-rest/rest/'
	const coverage = '/wxh-worker-rest/rest/coverage/'
	const parts = '/wxh-worker-rest/rest/parts/'
	const base = '/wxh-worker-rest/rest/base/'
	const formType = {'content-type': 'application/x-www-form-urlencoded'}
	const dataType = {'content-type': 'multipart/form-data'}

	/**
	 * 配件申请单-查询网点地址信息
	 */
	let getSiteAddress = async () => await vm.$u.get(coverage + vm.vuex_token + '/getSiteAddress');
	/**
	 * 配件申请单-修改网点地址信息
	 */
	let updateAddress = async (params = {}) => await vm.$u.post(coverage + vm.vuex_token + '/updateSiteAddress', params, formType);
	/**
	 * 配件过滤-品类列表
	 */
	let getCategoryList = async () => await vm.$u.get(base + vm.vuex_token + '/allow/category/list');
	/**
	 * 配件过滤-一级分类
	 */
	 let getClassify = async (params = {}) => await vm.$u.get(parts + vm.vuex_token + '/type/classify/' + params.id);
	/**
	 * 配件过滤-品牌列表
	 */
	let getBrandList = async (params = {}) => await vm.$u.get(parts + vm.vuex_token + '/type/towLevel/' + params.categoryId + '/' + params.classifyId);
		/**
	 * 配件过滤-三级分类列表
	 */
	let getThreeLevel = async (params = {}) => await vm.$u.get(parts + vm.vuex_token + '/type/threeLevel/' + params.categoryId + '/' + params.classifyId + '?partnerCompanyId=' + params.partnerCompanyId + '&speciesId=' + params.speciesId);
	/**
	* 查询配件列表
	*/
	let getPartsList = async (params = {}) => await vm.$u.get(parts + vm.vuex_token + '/parts/v2', params);
	/**
	 * 配件申请单-创建申请单/使用物料
	 */
	let applyParts = async (params = {}) => await vm.$u.post(parts + vm.vuex_token + '/orders', params, dataType)
	let createParts = async (params = {}) => await vm.$u.post(parts + vm.vuex_token + '/orders/create', params, formType)

	/**
	 *  查询自己的物料仓
	 */
	let getMyReserve = async (params = {}) => await vm.$u.get(parts + vm.vuex_token + '/items/v2/reserve', params);
	/**
	 *  查询工单的配件明细
	 */
	let getWorkOrderParts = async (params = {}) => await vm.$u.get(parts + vm.vuex_token + '/items/workOrder/' + params.workOrderId);
	/**
	 * 返件-物料/新件
	 */
	let returnParts = async (params = {}) => await vm.$u.post(parts + vm.vuex_token + '/return/new', params, formType);

	const partsApi = {
		getSiteAddress,
		updateAddress,
		getCategoryList,
		getClassify,
		getBrandList,
		getThreeLevel,
		getPartsList,
		applyParts,
		getMyReserve,
		getWorkOrderParts,
		returnParts,
		createParts
	}
	return partsApi
}
module.exports = {
	partsApiFun
}