import createAxios from '@/utils/request'
export type ProcessDefinitionVO = {
    id: string
    version: number
    deploymentTIme: string
    suspensionState: number
}
export type ModelVO = {
    id: number
    formName: string
    key: string
    name: string
    description: string
    category: string
    formType: number
    formId: number
    formCustomCreatePath: string
    formCustomViewPath: string
    processDefinition: ProcessDefinitionVO
    status: number
    remark: string
    createTime: string
    bpmnXml: string
}
//登录获取token
export function getRouteMenu() {
    return createAxios({
        url: '/user-boot/function/getRouteMenu'
    })
}

export const getModelPage = async (params: any) => {
    return await createAxios({ url: '/process-boot/bpm/model/page', params, method: 'get' })
}

export const getModel = async (id: number) => {
    return await createAxios({ url: '/process-boot/bpm/model/get?id=' + id, method: 'get' })
}

export const updateModel = async (data: any) => {
    return await createAxios({ url: '/process-boot/bpm/model/update', method: 'put', data: data })
}

// 任务状态修改
export const updateModelState = async (id: number, state: number) => {
    const data = {
        id: id,
        state: state
    }
    return await createAxios({ url: '/process-boot/bpm/model/update-state', method: 'put', data: data })
}

export const save = async (data: any) => {
    return await createAxios({ url: '/process-boot/flowable/definition/save', method: 'POST', data: data })
}

export const deleteModel = async (id: number) => {
    return await createAxios({ url: '/process-boot/bpm/model/delete?id=' + id, method: 'DELETE' })
}

export const deployModel = async (id: number) => {
    return await createAxios({ url: '/process-boot/bpm/model/deploy?id=' + id, method: 'POST' })
}
export const readXml = async (id: number) => {
    return await createAxios({ url: 'process-boot/flowable/definition/readXml?deployId=' + id, method: 'GET' })
}
export const assFormWithDeploy = async (data: any) => {
    return createAxios({ url: '/process-boot/flowable/definition/assFormWithDeploy', method: 'GET', params: data })
}
export const deleteDeploy = async (data: any) => {
    return createAxios({ url: 'process-boot/flowable/definition/delete', method: 'POST', data })
}
export const flowRecord = async (data: any) => {
    return createAxios({ url: '/process-boot/flowable/task/flowRecord', method: 'GET', params: data })
}
export const flowXmlAndNode = async (data: any) => {
    return createAxios({ url: '/process-boot/flowable/task/flowXmlAndNode', method: 'GET', params: data })
}
