import request from '@/utils/request'

const baseUrl = import.meta.env.VITE_APP_BASE_API

// 查询外协商列表
export function list(data) {
	return request({
		url: baseUrl + '/business/supplier/list',
		method: 'get',
		params: data
	})
}
export function listByDept(data) {
	return request({
		url: baseUrl + '/business/supplier/listByDept',
		method: 'get',
		params: data
	})
}
export function listOutsourceDeptList(data) {
	return request({
		url: baseUrl + '/business/supplier/getOutsourceDept',
		method: 'get',
		params: data
	})
}


// 获取外协商信息
export function getInfo(id) {
	return request({
		url: baseUrl + '/business/supplier/getInfo/' + id,
		method: 'get'
	})
}

// 新增外协商
export function save(data) {
	return request({
		url: baseUrl + '/business/supplier/save',
		method: 'post',
		data: data
	})
}

// 删除外协商
export function remove(id) {
	return request({
		url: baseUrl + '/business/supplier/remove/' + id,
		method: 'delete'
	})
}

// 查询外协商对应的产品列表
export function getSupplierProduct(data) {
	return request({
		url: baseUrl + '/business/supplier/getSupplierProduct',
		method: 'get',
		params: data
	})
}
// 查询外协商对应的联系人
export function getSupplierContacts(data) {
	return request({
		url: baseUrl + '/business/supplier/getSupplierContacts',
		method: 'get',
		params: data
	})
}

// 查询外协商对应的产品列表
// 通过post，是不需要分页的
export function getSupplierProductProcess(data) {
	return request({
		url: baseUrl + '/business/supplier/getSupplierProductProcess',
		method: 'post',
		data: data
	})
}

// 保存外协商对应的产品列表
export function saveSupplierProduct(data) {
	return request({
		url: baseUrl + '/business/supplier/saveSupplierProduct',
		method: 'post',
		data: data
	})
}

// 保存外协商对应的联系人
export function saveSupplierContacts(data) {
	return request({
		url: baseUrl + '/business/supplier/saveSupplierContacts',
		method: 'post',
		data: data
	})
}

// 保存外协商对应的产品对应的工序列表
export function saveSupplierProductProcess(data) {
	return request({
		url: baseUrl + '/business/supplier/saveSupplierProductProcess',
		method: 'post',
		data: data
	})
}

// 删除外协商对应的产品列表
export function removeSupplierProduct(id) {
	return request({
		url: baseUrl + '/business/supplier/removeSupplierProduct/' + id,
		method: 'delete'
	})
}

// 删除外协商对应的产品对应的工序列表
export function removeSupplierProductProcess(id) {
	return request({
		url: baseUrl + '/business/supplier/removeSupplierProductProcess/' + id,
		method: 'delete'
	})
}

/*********************************************** 管理员相关 ***********************************************/
// 获取外协商管理员信息（每个供应商只能有一个唯一的管理员）
export function getAdminInfo(supplierId) {
	return request({
		url: baseUrl + '/business/supplier/getAdminInfo/' + supplierId,
		method: 'get'
	})
}

// 保存外协商管理员
export function saveAdmin(data) {
	return request({
		url: baseUrl + '/business/supplier/saveAdmin',
		method: 'post',
		data: data
	})
}

// 初始化外协商管理员密码
export function initAdminPsw(data) {
	return request({
		url: baseUrl + '/business/supplier/initAdminPsw',
		method: 'post',
		data: data
	})
}
