// 导入接口调用文件
import { request } from './request'
const obj = {
    // 通过字典类型获取字典值
    getDictionary: async (type) => {
        let res = await request({
            method: 'GET',
            url: 'dict-byType',
            data: {type: type}
        }, true)
        if (res.code === 0) {
            let obj = {
                obj: {},
                list: res.data.map(ele => {
                    return ele.label
                })
            }
            
            obj.list.unshift('全部')
            res.data.map(ele => {
                obj.obj[ele.label] = ele.value
            })
            return obj
        }
    },
    // 通过字典类型获取字典值,不包括全部
    getDictionarynoall: async (type) => {
        let res = await request({
            method: 'GET',
            url: 'dict-byType',
            data: {type: type}
        }, true)
		if (res.code === 0) {
		    let obj = {
		        obj: {},
		        list: res.data.map(ele => {
		            return ele.label
		        }),
				data: res.data
		    }
		    res.data.map(ele => {
		        obj.obj[ele.label] = ele.value
		    })
		    return obj
		}
    },
	// 通过字典类型获取所有字典值的数据
	getDictionarySpecial: async (type) => {
	    let res = await request({
	        method: 'GET',
	        url: 'dict-byType',
	        data: {type: type}
	    }, true)
		if (res.code === 0) {
		    let obj = {
		        obj: {},
		        list: res.data
		    }
		    res.data.map(ele => {
		        obj.obj[ele.label] = ele.value
		    })
		    return obj
		}
	}
}
export default obj
