import axios from '@/utils/http';
const base = process.env.VUE_APP_SERVER + '/template';
const template = {
    list(params: any) {
        return axios.post(`${base}/list`, {
            // template_type: 0,
            // page: 1,
            // page_size: 20,
            ...params,
        });
    },
    systemList(params: any) {
        return axios.post(`${base}/systemList`, {

        });
    },
    get(id: number, params: any) {
        return axios.get(`${base}/get?id=${id}`, {
            ...params,
        });
    },
    folderList(params: any) {
        return axios.post(`${base}/folderList`, {
            template_type: 0,
            page: 1,
            page_size: 20,
            ...params,
        });
    },
    delete(id: number, params: any = {}) {
        return axios.delete(`${base}/deleteFolder`, {
            data: {
                id,
            },
            ...params,
        });
    },
    getFolder(id: string) {
        return axios.get(`${base}/getFolder`, {
            params: {
                id,
            },
        });
    },
    addFolder(name: string, params: any) {
        return axios.post(`${base}/addFolder`, {
            name,
            info: '-',
            ...params,
        });
    },
    updateFolder(params: any) {
        const {folder_id, folder_name} = params;
        return axios.put(`${base}/updateFolder`, {
            id: folder_id,
            name: folder_name,
        });
    },
    customize(name: string, detail: any, folderId: number, params: any) {
        return axios.post(`${base}/customize`, {
            name,
            detail: JSON.stringify(detail),
            info: '自定义模板',
            s_image_url: '',
            folder_id: folderId,
            ...params,
        });
    },
    searchCustomize(key: string, params: any) {
        return axios.post(`${base}/searchCustomize`, {
            key,
            ...params,
        });
    },
    deleteTemplate(id: number, params: any = {}) {
        return axios.delete(`${base}/deleteCustomize`, {
            data: {
                id,
            },
            ...params,
        });
    },
    updateCustomize(params: any) {
        return axios.put(`${base}/updateCustomize`, {
            ...params,
        });
    },
    getTemplate(id: string) {
        return axios.get(`${base}/get`, {
            params: {
                id,
            },
        });
    },
};
export default template;
