import request from '@/utils/request'
import { AxiosPromise } from 'axios'

// apiUrl 字典管理
const api = {
	page: '/sys/dict/page',
	listParent: '/sys/dict/list-parent',
	create: '/sys/dict/create',
	update: '/sys/dict/update',
	delete: '/sys/dict/delete'
}
/**
 * 字典管理  - 列表
 */
function dictPageApi(data: any): AxiosPromise {
	return request({
		url: api.page,
		method: 'post',
		data
	})
}

function dictListParentApi(): AxiosPromise {
	return request({
		url: api.listParent,
		method: 'get'
	})
}

/**
 * 字典管理  - 新增编辑保存
 */
function dictAddOrEditSaveApi(data: any): AxiosPromise {
	return request({
		url: data.id ? api.update : api.create,
		method: 'post',
		data
	})
}

/**
 * 字典管理  - 删除
 */
function dictDeleteApi(data: any): AxiosPromise {
	return request({
		url: api.delete,
		method: 'post',
		data
	})
}
export default {
	dictPageApi,
	dictListParentApi,
	dictAddOrEditSaveApi,
	dictDeleteApi
}
