<template>
  <div class="app-container">
    <j-table
      v-loading="loading"
      :show-selection="false"
      :data="tableData"
      :columns="columns"
      :pagination="pagination"
    >
      <el-table-column label="操作" align="center" fixed="right" width="180" class-name="small-padding fixed-width">
        <template slot-scope="{ row }">
          <el-button
            v-hasPermi="['common:permission:query']"
            size="mini"
            type="text"
            @click="$refs.authDialogRef.handleEdit(row, true)"
          >详情</el-button>
          <el-button
            v-hasPermi="['common:permission:edit']"
            size="mini"
            type="text"
            @click="$refs.authDialogRef.handleEdit(row)"
          >编辑</el-button>
        </template>
      </el-table-column>
    </j-table>

    <auth-dialog ref="authDialogRef" @ok="loadData" />
  </div>
</template>
<script>
import JTable from '@/components/Table/index.vue'
import AuthDialog from '@/views/system/setting/modules/AuthDialog.vue'
import { fetchSettingCommonPage } from '@/api/system/setting'
export default {
  name: 'Setting',
  components: {
    JTable,
    AuthDialog
  },
  data() {
    return {
      loading: false,
      tableData: [],
      pagination: {
        total: 0,
        pageNum: 1,
        pageSize: 10
      },
      columns: [
        { prop: 'serviceName', label: '权限名称', minWidth: 200, align: 'left' },
        { prop: 'remark', label: '备注', align: 'left' },
        { prop: 'createNickName', label: '创建人', minWidth: 120, align: 'left' },
        { prop: 'createTime', label: '创建时间', minWidth: 160 }
      ]
    }
  },
  created() {
    this.loadData()
  },
  methods: {
    loadData() {
      this.loading = true
      fetchSettingCommonPage(this.pagination).then(({ data, total }) => {
        this.tableData = data
        this.pagination.total = total
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>
