import request from '/@/utils/request';
import { AxiosPromise  } from 'axios';
import type { ItemType, ICopyFromParams } from './types';

export function Add(params: string) {
	return request({
		url: '/inventory/item/type/info/add',
		method: 'post',
		data: params,
	});
}
export function update(params: string) {
	return request({
		url: '/inventory/item/type/info/update',
		method: 'post',
		data: params,
	});
}
export function deleteId(params: string) {
	return request({
		url: '/inventory/item/type/info/delete',
		method: 'post',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		data: params,
	});
}
export function list(params: object): AxiosPromise<{ list: ItemType[] }> {
    return request({
      url: '/inventory/item/type/info/list',
      method: 'post',
      params
    })
}


/**
 * 更新库存字典类型显示状态
 * @param params 
 * @returns 
 */
export function updateShowStateApi(params: { clientCode: string; typeCode: string; showState: 0 | 1}) {
	return request({
		url: '/inventory/item/type/info/updateShowState',
		method: 'post',
		headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		params: params
	})
}


/**
 * 从其它医院导入物品至新医院
 * @param params 
 * @returns 
 */
export function copyFromApi(params: ICopyFromParams) {
	return request({
		url: '/inventory/item/detail/info/copyFrom',
		method: 'post',
		headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		params: params
	})
}