You need to sign in or sign up before continuing.
base.js 1.21 KB
import { fetchBase } from './fetch.js'
import { setSessionStorage, getSessionStorage } from '@/utils/common.js'

// 获取字典
export function getDict() {
    return fetchBase({ url: `/tumour-admin/v1/h5-app/dict`, loading: true })
}

// 区划编码查询下级
export function getAreaChild(parentCode, loading = true) {
    const key = 'chronic-area-cache'
    return new Promise((resolve, reject) => {
        const result = getSessionStorage(key) || {}
        if (result[parentCode]) {
            resolve(result[parentCode])
            return 
        }
        fetchBase({ url: `/tumour-admin/v1/h5-app/child-area/${parentCode}`, loading }).then(res => {
            result[parentCode] = res.data
            setSessionStorage(key, result)
            resolve(res.data)
        }).catch(err => {
            reject(err)
        })
    })
}

// 居民基本信息查询
export function getResidentInfo(idCard) {
    return fetchBase({ url: `/tumour-admin/v1/h5-app/residents/${idCard}`, loading: true })
}

// 居民idCard或者tel查询居民信息
export function getResidentByInfo(params) {
    return fetchBase({ url: `/chronic-resident/v1/chronic-residents-record/query-resident-info-by-id-card`, body: params, loading: true })
}