import request from '@/assets/js/utils/request'

// 菜单列表获取
export function fetchMenuList() {
  return request({
    url: '/bidprocurement/common-user/user/function/getFunctionList',
    method: 'get'
  })
}

// 菜单添加
export function createMenu(data) {
  return request({
    url: '/bidprocurement/common-user/user/function/addFunction',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

// 排序
export function changeSort(rowId, value) {
  return request({
    url:
      '/bidprocurement/user/roleManagement/function/changeSort' +
      '?rowId=' +
      rowId,
    method: 'post',
    data: { sort: value }
  })
}

// 编辑菜单
export function updateMenu(data) {
  return request({
    url: '/bidprocurement/common-user/user/function/updateFunction',
    method: 'post',
    data
  })
}

// 删除菜单
export function deleteMenu(id) {
  return request({
    url: '/bidprocurement/common-user/user/function/deleteFunction' + '?id=' + id,
    method: 'post'
  })
}

// ???
export function generateButton(data) {
  return request({
    url:
      '/bidprocurement/user/roleManagement/function/generate/button' +
      '?id=' +
      data.functionId,
    method: 'post',
    data
  })
}
