import request from '@/router/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/bank/autostruct/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const getDetail = (id) => {
  return request({
    url: '/api/bank/autostruct/detail',
    method: 'get',
    params: {
      id
    }
  })
}

export const getSelectAndPermissionByDept = () => {
  return request({
    url: '/api/bank/autostruct/getSelectAndPermissionByDept',
    method: 'get',
    params: {
    }
  })
}

export const remove = (ids) => {
  return request({
    url: '/api/bank/autostruct/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/api/bank/autostruct/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/api/bank/autostruct/submit',
    method: 'post',
    data: row
  })
}

export const opStr2opObj = (optionStr) => {
  optionStr = optionStr.replace(/(s*?{s*?|s*?,s*?)(['"])?([a-zA-Z0-9]+)(['"])?:/g, '$1"$3":');
  optionStr = optionStr.replace(/\'/ig,"\"")
  optionStr = optionStr.replace(/&gt;/ig,">")
  optionStr = optionStr.replace(/\s*/g, '')
  // str.replace(/\s*/g,"")
  let optionObj = JSON.parse(optionStr, (k,v)=>{
    if(k == 'change'){
      return eval(v)
    }
    return v
  })
  return optionObj;
}
