import { defHttp } from '@/utils/http/axios';
import {
  AccountListGetResultModel,
  AccountParams,
  SaveFormsParams,
  DeleteFormsParams,
} from './model/index';

enum Api {
  GETDESIGNDATA = '/api/FormModule/GetEntityByCode', //获取设计数据
  GETFORMPAGEDATA = '/api/FormScheme/GetFormDataPage?id=', //获取表单分页数据
  SAVEFORMDATA = '/api/FormScheme/SaveForm', //新增编辑自定义表单
  DELFORMSDATA = '/api/FormScheme/DeleteFormData?id=', //删除表单数据
  GETFORMSDATADETAIL = '/api/FormScheme/GetFormData', //删除表单数据详情
}

/**
 * @description: Get sample options value
 */
export const getFormsDesignData = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel[]>({ url: Api.GETDESIGNDATA, params });
export const getFormsPageData = (params: AccountParams) =>
  defHttp.post<AccountListGetResultModel[]>({ url: Api.GETFORMPAGEDATA + params.id, params });
export const saveFormsData = (params: SaveFormsParams) =>
  defHttp.post<AccountListGetResultModel[]>({ url: Api.SAVEFORMDATA, params });
export const delFormsData = (params: DeleteFormsParams) =>
  defHttp.post<AccountListGetResultModel[]>({
    url: Api.DELFORMSDATA + params.id + '&key=' + params.key + '&keyValue=' + params.keyValue,
    params,
  });
export const getFormsDataDetail = (params: DeleteFormsParams) =>
  defHttp.get<AccountListGetResultModel[]>({ url: Api.GETFORMSDATADETAIL, params });
