/*
 * @Author: your name
 * @Date: 2021-12-24 11:36:07
 * @LastEditTime: 2022-02-09 10:59:01
 * @LastEditors: Please set LastEditors
 * @Description: 权限公用
 * @FilePath: \Foshan4A2.0\src\views\authorityManagement\minixs\roleData.js
 */
import { QueryRole, DeleteRole } from '@/api/apiAuthority'
import { Query, GeneralDataReception } from '@/api/dataIntegration'

export default {
  data () {
    return {
      dataList: [],
      msgIndex: null
    }
  },
  created () {
    // this.gueryRole()
  },
  methods: {
    //获取列表数据
    async gueryRole (obj) {
      try {
        this.loading = true
        const res = await Query(obj)
        if (res.code == 0) {
          const newDatas = res.returnData.listValues
          if (newDatas && newDatas.length) {
            this.total = res.returnData.pages
            newDatas.forEach(element => {
              this.arrs.push(element)
            })
            this.msgIndex = this.needPage
          } else {
            this.total = this.msgIndex
            this.needPage = this.msgIndex
          }
          this.loading = false
        } else {
          this.$message.error(res.message)
          this.loading = false
        }
      } catch (error) {
        console.log('出错了', error)
        this.loading = false
      }
    },

    //删除角色
    async deleteRole (id, num) {
      try {
        const res = await DeleteRole({
          RoleId: id
        })
        if (res.code === 0) {
          this.flag = false
          this.$message.success(res.message)
          this.arrs.splice(num, 1)
          this.num = null
        } else {
          this.flag = false
          this.$message.error(res.message)
        }
      } catch (error) {
        this.flag = false
        console.log('出错了', error)
      }
    }
  }
}
