import { main, dict, loginUrl, file, FileApi, User } from '@/api'
import request from '@/utils/require'

export const enumStatus = [
	{
		value: '91000050',
		label: '暂存',
	},
	{
		value: '91000051',
		label: '已发送',
	},
	{
		value: '91000052',
		label: '尚不可退款',
	},
	{
		value: '91000053',
		label: '可退款',
	},
	{
		value: '91000054',
		label: '已确认',
	},
	{
		value: '91000055',
		label: '已退款',
	},
]
//获取状态文案
export function getStatusText(statusCode) {
	if (!statusCode) return
	return this.enumStatus.find(item => item.value == statusCode).label
}

//获取退保证金委托函列表
export function getRefundDelegationList(data) {
	return request({
		url: `${main}/transaction/manager/givebackbail/giveBackBailLetter/selectOwnerPageByEntity?pageNum=${data.pageIndex}&pageSize=${data.pageSize}`,
		method: 'post',
		data: data,
	})
}
//退保证金委托函新增
export function addRefundDelegation(data) {
	return request({
		url: `${main}/transaction/manager/givebackbail/giveBackBailLetter/insertEntitySelective`,
		method: 'post',
		data: data,
	})
}
//退保证金委托函修改
export function updateRefundDelegation(data) {
	return request({
		url: `${main}/transaction/manager/givebackbail/giveBackBailLetter/updateByEntitySelective`,
		method: 'post',
		data: data,
	})
}
//退保证金委托函详细信息
export function getRefundDelegationDetail(data) {
	return request({
		url: `${main}/transaction/manager/givebackbail/giveBackBailLetter/selectById`,
		method: 'post',
		data: data,
	})
}
//更新退保证金委托函状态
export function updateRefundDelegationStatus(data) {
	return request({
		url: `${main}/transaction/manager/givebackbail/giveBackBailLetter/updateStatusByEntity`,
		method: 'post',
		data: data,
	})
}

//接收保证金列表
export function getReceiveDelegationList(data) {
	return request({
		url: `${main}/transaction/manager/givebackbail/giveBackBailLetter/selectReceivePageByEntity?pageNum=${data.pageIndex}&pageSize=${data.pageSize}`,
		method: 'post',
		data: data,
	})
}

export function getOrgTree() {
	return request({
		url: `${User}/org/tree?orgCode=LS001`,
		method: 'post',
	})
}

//保证金退款列表
//
export function getMarginRefundList(data) {
	return request({
		url: `${main}/transaction/giveback/selectGiveBackPageList?pageNum=${data.pageIndex}&pageSize=${data.pageSize}`,
		method: 'post',
		data,
	})
}

//未成交保证金退款列表
//
export function selectPassBackPageList(data) {
	return request({
		url: `${main}/transaction/giveback/selectPassBackPageList?pageNum=${data.pageIndex}&pageSize=${data.pageSize}`,
		method: 'post',
		data,
	})
}

//保证金退款详情
export function getMarginRefundDetail(data) {
	return request({
		url: `${main}/transaction/giveback/selectGiveBackDetail`,
		method: 'post',
		data,
	})
}

//未成交保证金退款详情
export function selectGiveBackPass(data) {
	return request({
		url: `${main}/transaction/giveback/selectGiveBackPass`,
		method: 'post',
		data,
	})
}

//场次列表
export function getTransactionSignUpAll(data) {
	return request({
		url: `${main}/transaction/transactionsignup/selectTransactionSignUpAll`,
		method: 'post',
		data,
	})
}
//业务部确认
export function confirmMarginRefundBusiness(data) {
	return request({
		url: `${main}/transaction/giveback/updateGiveBackBusiness`,
		method: 'post',
		data,
	})
}
//财务部确认
export function confirmFinancial(data) {
	return request({
		url: `${main}/transaction/giveback/updateGiveBackFinance`,
		method: 'post',
		data,
	})
}

export function fileInfo(data) {
	return request({
		url: `${FileApi}/file/findByIds?ids=${data}`,
		method: 'get',
	})
}
export function fileDownload(data) {
	return request({
		url: `${FileApi}/file/download?id=${data}`,
		method: 'get',
	})
}

// ;/transaction/trademark / selectContractList / { id }
// 获取场次对应的合同下拉列表
export function selectContractList(id) {
	return request({
		url: `${main}/transaction/trademark/selectDWmcList/${id}`,
		method: 'post',
	})
}
export function selectContractByDwbm(id, ccbm) {
	return request({
		url: `${main}/transaction/trademark/selectContractByDwbm/${id}/${ccbm}`,
		method: 'post',
	})
}


//未成交修改
export function updateGiveBackPass(data) {
	return request({
		url: `${main}/transaction/giveback/updateGiveBackPass`,
		method: 'post',
		data,
	})
}

//单位下拉
export function selectGivePassAll(data) {
	return request({
		url: `${main}/transaction/giveback/selectGivePassAll`,
		method: 'post',
		data,
	})
}

//下拉带出
export function selectPassBack(data) {
	return request({
		url: `${main}/transaction/giveback/selectPassBack`,
		method: 'post',
		data,
	})
}
//
export function selectTkdwList() {
	return request({
		url: `${main}/transaction/manager/givebackbail/giveBackBailLetter/selectTkdwList`,
		method: 'post',
	})
}
//
export function selectTkdwHtList(dwbm) {
	return request({
		url: `${main}/transaction/manager/givebackbail/giveBackBailLetter/selectTkdwHtList/${dwbm}`,
		method: 'post'
	})
}
