/*
 * @Author: your name
 * @Date: 2021-12-24 11:36:07
 * @LastEditTime: 2022-01-07 11:29:53
 * @LastEditors: Please set LastEditors
 * @Description: 权限公用
 * @FilePath: \Foshan4A2.0\src\views\authorityManagement\minixs\roleData.js
 */
import { GetRoleByGroup } from '@/api/AccountGroup'
export default {
  data () {
    return {
      arrs: []
    }
  },
  methods: {
    // 根据岗位获取角色
    async getRoleByGroup (id) {
      try {
        const res = await GetRoleByGroup({
          GroupId: id
        })
        if (res.code === 0) {
          const arr = res.returnData
          if (id == -1) {
            arr.forEach(item => {
              item.name = item.RoleName
            });
            this.arrs = arr
          } else {
            const datas = []
            arr.forEach(item => {
              item.name = item.RoleName
              if (item.IsSelected == 1) {
                datas.push(item)
              }
            });
            this.arrs = datas
          }
        } else {
          this.$message.error(res.message)
        }
      } catch (error) {
        console.log('出错了', error)
      }
    },
  }
}
