<template>
  <el-dialog
    title="数据权限"
    append-to-body
    :visible.sync="dialogVisible"
    destroy-on-close
    width="1000px"
    @close="close"
    @open="open"
  >
    <!--表格渲染-->
    <el-table
      ref="table"
      v-loading="crud.loading"
      :data="crud.data"
      style="width: 100%;"
      size="mini"
      border
      :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
    >
      <el-table-column prop="permission_scope_type" label="权限类型" min-width="100" show-overflow-tooltip />
      <el-table-column prop="permission_name" label="权限范围" min-width="100" show-overflow-tooltip />
      <el-table-column prop="dept_name" label="部门名称" min-width="100" show-overflow-tooltip />
      <el-table-column prop="person_name" label="用户名称" min-width="100" show-overflow-tooltip />
    </el-table>
    <!--分页组件-->
    <pagination />
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>

import CRUD, { header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination'

export default {
  name: 'ShowDataPermissionDialog',
  components: { rrOperation, pagination },
  cruds() {
    return CRUD({ title: '权限明细', idField: 'user_id', url: 'api/dataPermission/dataDetail'})
  },
  mixins: [presenter(), header()],
  dicts: ['product_series'],
  props: {
    dialogShow: {
      type: Boolean,
      default: false
    },
    currentUserId: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      dialogVisible: false,
      classes: [],
      tableRadio: null,
      rows: []
    }
  },
  watch: {
    dialogShow: {
      handler(newValue) {
        this.dialogVisible = newValue
      }
    }
  },
  methods: {
    clickChange(item) {
      this.tableRadio = item
    },
    open() {
      console.log(this.currentUserId)
    },
    close() {
      this.crud.resetQuery(false)
      this.$emit('update:dialogShow', false)
    },
    [CRUD.HOOK.afterRefresh]() {
      this.open()
    }
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .el-dialog__body {
  padding-top: 0px;
}
</style>

