<template>
  <el-dialog v-dialogDrag :title="this.$t('orderAuthor.packingDetails')" :visible.sync="dialogShow" width="800px" :before-close="close">
    <div>
      <QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogShow = false">{{ $t('map.cancel') }}</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { getPermissonDetail } from '@/api/management/author';

export default {
    name: 'Author',
    components: {
    },
    props:{
        permissionTypeList:{
            required:true,
            type:Array
        }
    },
    data() {
        return {
            dialogShow: false,
            id: '',
            pagerConfig: {
                pageSize: 'pageSize',
                pageIndex: 'pageNum'
            },
            queryForm: {
                labelWidth: '140px',
                reset: true,
                show: false,
                queryObject: {
                }
            },
            queryList: {
                query: this.queryFunction,
                selectCheckShow: false,
                indexShow: true,
                columns: [
                    {
                        title: this.$t('orderAuthor.permissionName'),
                        prop: 'name'
                    },
                    {
                        title: this.$t('orderAuthor.permissionType'),
                        prop: 'type',
                        type: 'tag',
                        columnValue: (row) => { return this.$convertField(row.type, this.permissionTypeList, ['value', 'label']); },
                        tagType: (row) => { return ''; }
                    }
                ],
                actions: [
                ]
            }
        };
    },
    methods: {
        doShow(id) {
            this.id = id;
            this.dialogShow = true;
            this.reloadTable();
        },
        close() {
            this.id = '';
            this.dialogShow = false;
        },
        queryFunction() {
            if (this.id) {
                return getPermissonDetail(this.id);
            }
        },
        reloadTable() {
            if (this.queryList && this.queryList.reload) {
                this.queryList.reload();
            }
        },
        turnback() {
            this.$router.go(-1);
        }
    }
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
    .draft {
        width: 400px;
        text-align: center;
        margin: 20px auto;
    }
</style>
