/*
 * @Author: zc
 * @description 业务管理-工单管理
 */
import request from '@/utils/request';
import qs from 'qs';

/**
 * @description 列表页面基础数据
 */
export const listBaseData = () => {
	return request({
		url: `/api/v1/Order/base-data`,
		method: 'get',
	});
};
/**
 * @description 工单列表
 * @param {any} params
 */
export const orderList = (params: any) => {
	return request({
		url: `/api/v1/Order`,
		method: 'get',
		params,
	});
};
/**
 * @description 工单列表(固定数量)
 * @param {any} params
 */
export const orderListFixed = (params: any) => {
	return request({
		url: `/api/v1/Order/fixed`,
		method: 'get',
		params,
	});
};
/**
 * @description 查询工单列表总数
 * @param {any} params
 */
export const orderListCount = (params: any) => {
	return request({
		url: `/api/v1/Order/count`,
		method: 'get',
		params,
	});
};
/**
 * @description 历史工单
 * @param {object} params
 */
export const historyOrder = (params: object) => {
	return request({
		url: `/api/v1/Order/history`,
		method: 'get',
		params,
	});
};
/**
 * @description 查询历史工单（全量）
 * @param {object} params
 */
export const historyOrderAll = (params: object) => {
	return request({
		url: `/api/v1/Order/history_all`,
		method: 'get',
		params,
	});
};
/**
 * @description 新增工单
 * @param {object} data
 */
export const orderAdd = (data: object) => {
	return request({
		url: `/api/v1/Order`,
		method: 'post',
		data,
	});
};
/**
 * @description 更新工单
 * @param {object} data
 */
export const orderEdit = (data: object) => {
	return request({
		url: `/api/v1/Order`,
		method: 'put',
		data,
	});
};
/**
 * @description 工单详情
 * @param {string} id
 */
export const orderDetail = (id: string | any[]) => {
	return request({
		url: `/api/v1/Order/${id}`,
		method: 'get',
	});
};
/**
 * @description 删除工单
 * @param {string} id
 */
export const orderDelete = (id: string) => {
	return request({
		url: `/api/v1/Order/${id}`,
		method: 'delete',
	});
};
/**
 * @description 查询工单办理流程开启参数
 * @param {object}id
 */
export const orderFlowParams = (id?: string) => {
	return request({
		url: `/api/v1/Order/startflow?orderId=${id}`,
		method: 'get',
	});
};
/**
 * @description 开始工单办理流程
 * @param data
 */
export const orderStartFlow = (data?: object) => {
	return request({
		url: `/api/v1/Order/startflow`,
		method: 'post',
		data,
	});
};
/**
 * @description 新增页面基础数据
 * @param {object} params
 */
export const orderBaseDataAdd = (params?: object) => {
	return request({
		url: `/api/v1/Order/base-data-add`,
		method: 'get',
		params,
	});
};
/**
 * @description 扩展表单页面基础数据
 * @param {object} params
 */
export const orderBaseExt = (params?: object) => {
	return request({
		url: `/api/v1/Order/base-data-ext`,
		method: 'get',
		params,
	});
};
/**
 * @description 获取热点下一级
 * @param {object} params
 */
export const hotSpotType = (params?: object) => {
	return request({
		url: `/api/v1/HotSpot/children`,
		method: 'get',
		params,
	});
};
/**
 * @description 查询热点
 * @param {string} params 热点名称
 */
export const hotSpotSearch = (params: string) => {
	return request({
		url: `/api/v1/Hotspot/children-hasname?name=${params}`,
		method: 'get',
	});
};
/**
 * @description 重复工单列表查询
 * @param {object} params
 */
export const duplicateOrder = (params?: object) => {
	return request({
		url: `/api/v1/Order/duplicate?${qs.stringify(params)}`,
		method: 'get',
	});
};
/**
 * @description 查询工单办理的期满时间配置
 * @param {object} params
 */
export const orderTimeConfig = (params?: object) => {
	return request({
		url: `/api/v1/Order/time-config`,
		method: 'get',
		params,
	});
};
/**
 * @description 查询企业信息
 * @param {object} params
 */
export const companyInfo = (params?: object) => {
	return request({
		url: `/api/v1/Enterprises/enterprise/list`,
		method: 'get',
		params,
	});
};
/**
 * @description 结束会签
 * @param {object} data
 */
export const endCounterSign = (data: object) => {
	return request({
		url: `/api/v1/Order/endcs`,
		method: 'post',
		data,
	});
};
/**
 * @description 取消延期
 * @param {object} data
 */
export const cancelDelay = (data: object) => {
	return request({
		url: `/api/v1/Order/delay/cancel`,
		method: 'post',
		data,
	});
};
/**
 * @description 工单办理
 * @param {object} data
 */
export const orderHandle = (data: object) => {
	return request({
		url: `/api/v1/Order/handle`,
		method: 'post',
		data,
	});
};
/**
 * @description 省退回批量申请
 * @param {object} data
 */
export const provinceReturn = (data: object) => {
	return request({
		url: `/api/v1/Order/send_back/batch`,
		method: 'post',
		data,
	});
};
/**
 * @description 导出交办单
 * @param {object} data
 */
export const exportJbOrder = (data: object) => {
	return request(
		{
			url: `/api/v1/ExportWord/order_submission_form`,
			method: 'post',
			responseType: 'blob',
			data,
		},
		{
			reduce_data_format: false,
		}
	);
};
/**
 * @description 工单导出 综合查询
 * @param {object} data
 */
export const exportOrder = (data: object) => {
	return request(
		{
			url: `/api/v1/Order/order/export`,
			method: 'post',
			responseType: 'blob',
			data,
		},
		{
			reduce_data_format: false,
		}
	);
};
/**
 * @description 副本工单列表
 * @param {object} params
 */
export const copyOrderList = (params: object) => {
	return request({
		url: `/api/v1/Order/order_copy/list`,
		method: 'get',
		params,
	});
};
/**
 * @description 工单撤销
 * @param {object} data
 */
export const orderRevoke = (data: object) => {
	return request({
		url: `/api/v1/OrderRevocation/add_order_revocation`,
		method: 'post',
		data,
	});
};
/**
 * @description 工单流程临时保存
 * @param {object} data
 */
export const orderProcessTempSave = (data: object) => {
	return request({
		url: `/api/v1/Order/steps/temp`,
		method: 'post',
		data,
	});
};
/**
 * @description 查询一级部门的下级部门
 * @param {object} params
 */
export const getDepartmentList = (params?:object) => {
	return request({
		url: `/api/v1/Org/cascade`,
		method: 'get',
		params
	});
};

/**
 * @description 跨级指派查询下一步可选节点及办理参数
 * @param {string} params
 */
export const orderAssignParams = (params: object) => {
	return request({
		url: `/api/v1/Order/nextsteps/cross`,
		method: 'get',
		params,
		paramsSerializer: (params:any) => qs.stringify(params)
	});
};
/**
 * @description 查询工单退回目标节点信息
 * @param {string} orderId
 */
export const orderReturnParams = (orderId: string | any) => {
	return request({
		url: `/api/v1/Order/previous/targetStep/${orderId}`,
		method: 'get',
	});
};
/**
 * @description 工单补充
 * @param {object} data
 */
export const orderComplement = (data: object) => {
	return request({
		url: `/api/v1/OrderComplement`,
		method: 'post',
		data,
	});
};
/**
 * @description 查询流转到坐席的次数
 * @param {string} id
 */
export const orderTransferCount = (id: string) => {
	return request({
		url: `/api/v1/Order/count-of-flow-to-seat/${id}`,
		method: 'get',
	});
};