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

class TreeconfigService {
  findIamEntity() {
    return axios({
      url: 'api/xcoa-mobile/v1/iamtreeconfig/findIamEntity/tableName',
      method: 'post',
      headers: {
        'Content-Type': 'application/json',
      },
    })
  }

  findIamForms() {
    return axios({
      url: 'api/xcoa-mobile/v1/iamtreeconfig/findIamEntity/formId',
      method: 'post',
      headers: {
        'Content-Type': 'application/json',
      },
    })
  }

  findIamEntityAttr(entityName) {
    return axios({
      url: 'api/xcoa-mobile/v1/iamtreeconfig/findIamEntityAttr/' + entityName,
      method: 'post',
      headers: {
        'Content-Type': 'application/json',
      },
    })
  }

  findIamPageChildren(params) {
    return axios({
      url: 'api/xcoa-mobile/v1/iamtreeconfig/findIamPageChildren',
      method: 'post',
      params,
    }).then((res) => {
      res.data.forEach((item) => (item.isLeaf = item.leaf))
      return res
    })
  }
}

export default new TreeconfigService()
