import request from '@/utils/request'

export function getTreeList(data) {
  return request({
    url: '/api/sy/dict/getTreeList',
    method: 'post',
    data
  })
}
export function getTxTreeList(data) {
  return request({
    url: '/api/sy/dict/getTxTreeList',
    method: 'post',
    data
  })
}
export function getList(data) {
  return request({
    url: '/api/sy/dict/getList',
    method: 'post',
    data
  })
}
export function getTree(data) {
  return request({
    url: 'api/sy/dict/getTreeListForQKFL',
    method: 'post',
    data
  })
}

export function del(data) {
  return request({
    url: '/api/sy/dict/del',
    method: 'post',
    data
  })
}
export function update(data) {
  return request({
    url: '/api/sy/dict/update',
    method: 'post',
    data
  })
}
export function Update(data) {
  return request({
    url: 'api/sy/dict/update',
    method: 'post',
    data
  })
}

export function add(data) {
  return request({
    url: '/api/sy/dict/add',
    method: 'post',
    data
  })
}

export function getByCode(data,flag=true) {
  if (flag){
    const localData=localStorage.getItem(data.dictCode);
    if (localData){
      return new Promise((resolve, reject)=>{
        const result={
          success:true,
          data:JSON.parse(localData).sort((a,b)=>{return a.itemCode-b.itemCode})
        }
        resolve(result);
      })
    }
  }
  return request({
    url: '/api/sy/dict/getbycode',
    method: 'post',
    data
  })
}

/**
 * 获取以dictCode分组的字典数据
 */
export function mapList() {
  return request({
    url: '/api/sy/dict/mapList',
    method: 'get'
  })
}

export function syLogAdd(data) {
  return request({
    url: '/api/sy/syLog/add',
    method: 'post',
    data
  })
}
export function syLogList(data) {
  return request({
    url: '/api/sy/syLog/getList',
    method: 'post',
    data
  })
}

export function syLogDel(data) {
  return request({
    url: '/api/sy/syLog/del',
    method: 'post',
    data
  })
}

export function getUser(data) {
  return request({
    url: '/api/sy/getUser',
    method: 'get',
    params: data
  })
}

/**
 * 根据字典编码查询,字典值编码右模糊查询
 * @param data
 * @returns {*}
 */
export function getByDictCodeWithItemCodeRightLike(data) {
  return request({
    url: '/api/sy/dict/getByDictCodeWithItemCodeRightLike',
    method: 'post',
    data
  })
}




