import qs from 'qs'
import axios from '@/common/services/axios-instance'

class BusinesstypeService {
  // 获取流程分类根节点
  getFlowTreeRoot(params) {
    return axios({
      url: `api/framework/v1/we-app-flow-design/app-flow-category`,
      method: 'get',
      params,
    })
  }

  // 获取个性流程分类根节点
  getNodeFlowTreeRoot(params) {
    return axios({
      url: `api/framework/v1/we-app-flow-design/app-node-flow-category`,
      method: 'get',
      params,
    })
  }

  // 获取流程分类树
  getFlowCateTree(params) {
    return axios({
      url: `api/framework/v1/process-prop/child-categories`,
      method: 'get',
      params,
    })
  }

  // 获取流程目录信息
  getFlowCateInfo(params) {
    return axios({
      url: `api/framework/v1/we-app-flow-design/flow-category`,
      method: 'get',
      params,
    })
  }

  // 创建流程目录
  createFlowCate(params) {
    return axios({
      url: `api/framework/v1/we-app-flow-design/create-flow-category`,
      method: 'post',
      data: params,
    })
  }

  // 编辑流程目录
  editFlowCate(params) {
    return axios({
      url: `api/framework/v1/we-app-flow-design/update-flow-category`,
      method: 'post',
      data: params,
    })
  }

  // 删除流程目录
  deleteFlowCate(params) {
    return axios({
      url: `api/framework/v1/we-app-flow-design/delete-flow-category?categoryId=${params.id}`,
      method: 'delete',
    })
  }

  // 创建流程
  createFlow(params) {
    return axios({
      url: `api/framework/v1/we-app-flow-design/create-flow`,
      method: 'post',
      data: params,
    })
  }

  // 从模板创建
  createFlowFormTemplate(params) {
    return axios({
      url: `api/framework/v1/we-app-flow-design/template-to-flow`,
      method: 'post',
      data: qs.stringify(params),
    })
  }

  // 编辑流程
  editFlow(params) {
    return axios({
      url: `api/framework/v1/we-app-flow-design/update-flow`,
      method: 'post',
      data: params,
    })
  }

  // 复制流程
  copyFlow(params) {
    return axios({
      url: `api/framework/v1/we-app-flow-design/copy-flow`,
      method: 'post',
      data: qs.stringify(params),
    })
  }

  // 删除流程
  deleteFlow(params) {
    return axios({
      url: `api/framework/v1/we-app-flow-design/delete-flow?flowIds=${params.ids}`,
      method: 'delete',
    })
  }

  // 存为模板
  save2template(params) {
    return axios({
      url: `api/framework/v1/we-app-flow-design/save-flow-to-template`,
      method: 'post',
      data: qs.stringify(params),
    })
  }

  // 获取流程信息
  getFlowInfo(params) {
    return axios({
      url: `api/framework/v1/we-app-flow-design/flow`,
      method: 'get',
      params,
    })
  }

  // 获取流程模板分类
  getFlowTemplateCate(params) {
    return axios({
      url: `api/framework/v1/we-app-flow-design/flow-template-cat`,
      method: 'get',
      params,
    })
  }

  // 获取流程模板列表
  getFlowTemlplateList(params) {
    return axios({
      url: `api/framework/v1/we-app-flow-design/flow-template`,
      method: 'get',
      params,
    })
  }
}

export default new BusinesstypeService()
