import {AxiosPromise} from 'axios'
import request from '@/utils/request'
import {PageParams, infoParams, TemplateResult, TemplateInfo} from "./types"


export const getTemplateInfoPages = (params: PageParams): AxiosPromise<TemplateResult> => {
    return request({
        url: '/api/design/template/info/pages',
        method: 'get',
        params,
    })
}

export const getTemplateDetailPages = (params: PageParams): AxiosPromise<TemplateResult> => {
    return request({
        url: '/api/design/template/detail/pages',
        method: 'get',
        params,
    })
}

export const getTemplateData = (pk: number): AxiosPromise<TemplateInfo> => {
    return request({
        url: `/api/design/template/data/${pk}`,
        method: 'get',
    })
}

export function getDesignTemplateEdit(data: any): any {
    return request({
        url: "apis10/design/getDesignTemplateEdit",
        method: "post",
        params: data,
    });
}

export function getPreViewTemplate(data: any): any {
    return request({
        url: "apis10/invoke/getPreViewTemplate",
        method: "post",
        params: data
    });
}

export function updateDesignTemplate(data: any): any {
    return request({
        url: "apis10/design/updateDesignTemplate",
        method: "post",
        data: data,
    });
}

export function tmpSaveUserDesign(data: any): any {
    return request({
        url: "apis10/design/tmpSaveUserDesign",
        method: "post",
        data: data,
    });
}

export function newDesignOrder(data: any, sessionId: string): any {
    return request({
        url: "apis10/invoke/newDesignOrder?outerSessionId=" + sessionId,
        method: "post",
        data: data
    });
}

