| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import { cacheFor } from '@/request/api/index';
- import type { Dictionaries, Fields, RegisterModel } from '@/request/model';
- import { fromRegisterFields, getPath} from '@/request/model';
- import { useVisitor } from '@/stores';
- import HTTP from '../alova';
- export function getCaptchaMethod(mobile: string) {
- return HTTP.Get<string>(`/fdhb-tablet/sms/sendVerCode`, {
- params: { phone: mobile },
- });
- }
- export function registerFieldsMethod(dictionaries?: Dictionaries) {
- return HTTP.Post<Fields, { tabletFileFields: string[] }>(`/fdhb-tablet/warrantManage/getPageSets`, void 0, {
- cacheFor, name: `variate:register_fields`,
- params: { k: 'register_fields' },
- transform(data, headers) {
- const options = data?.tabletFileFields ?? [];
- return fromRegisterFields(options, dictionaries);
- },
- });
- }
- export function registerVisitorMethod() {
- return HTTP.Get<string, string>(`/fdhb-tablet/patientInfoManage/createTourist`, {
- name: 'register',
- cacheFor: null,
- })
- }
- export function registerAccountMethod(params: Partial<RegisterModel>) {
- return HTTP.Post<string, string>(`/fdhb-tablet/patientInfoManage/savePatientInfo`, params, {
- name: 'register',
- transform(data) {
- const Visitor = useVisitor();
- Visitor.patientId = data;
- return data;
- },
- });
- }
- export function searchAccountMethod(params: Partial<RegisterModel>) {
- return HTTP.Get(`/fdhb-tablet/patientInfoManage/getPatientInfoDetail`, {
- hitSource: 'register',
- params,
- transform(data: Record<string, any>, headers) {
- return Object.fromEntries(Object.entries(data).filter(([ item, value ]) => !!value)) as Partial<RegisterModel>;
- },
- });
- }
- export function scanAccountMethod(key: string) {
- return HTTP.Get(`/fdhb-tablet/patientInfoManage/getPatInfoByScanCode`, {
- hitSource: 'register',
- params: { scanCode: key },
- transform(data: Record<string, any>, headers) {
- const { id: patientId, processModule, ..._data } = data;
- if ( patientId ) useVisitor().patientId = patientId;
- return {
- key, patientId, path: getPath(processModule),
- model: Object.fromEntries(Object.entries(_data).filter(([ item, value ]) => !!value)) as Partial<RegisterModel>,
- };
- },
- });
- }
- export function dictionariesMethod() {
- return HTTP.Get<Dictionaries | void, any>(`/fdhb-tablet/dict/getDicts`, {
- cacheFor, name: `variate:dict`,
- transform(data) {
- if (!Array.isArray(data)) return void 0;
- const dictionaries: Dictionaries = new Map();
- for (const { dictType, items } of data) dictionaries.set(dictType, items.map((item: any) => ({label: item.dictLabel, value: item.dictValue })));
- return dictionaries.size ? dictionaries : void 0;
- },
- });
- }
|