<template>
  <div>
    <QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
  </div>
</template>

<script>
import { superAdmin } from '@/router';
import { listPackagePermission } from '@/api/management/distribute';
// import { UrlConfig } from '@/router/index';

export default {
	name: 'Author',
	components: {
	},
	data() {
		return {
			pagerConfig: {
				pageSize: 'pageSize',
				pageIndex: 'pageNum'
			},
			queryForm: {
				labelWidth: '120px',
				reset: true,
				queryObject: {
					'userName': {
						type: 'text',
						label: this.$t('orderAuthor.userName')
					},
					'userMobile': {
						type: 'text',
						label: this.$t('global.mobile')
					}
				}
			},
			queryList: {
				query: this.queryFunction,
				selectCheckShow: false,
				indexShow: true,
				columns: [
					{
						title: this.$t('orderAuthor.organizationOrEnterprise'),
						prop: 'organizationName'
					},
					{
						title: this.$t('orderAuthor.founder'),
						prop: 'userName'
					},
					{
						title: this.$t('orderAuthor.founderPhone'),
						prop: 'userMobile'
					},
					{
						title: this.$t('orderAuthor.mapName'),
						prop: 'mapName'
					},
					{
						title: this.$t('orderAuthor.mapProductName'),
						prop: 'mapProductName'
					},
					{
						title: this.$t('orderAuthor.courseName'),
						prop: 'lessonName'
					},
					{
						title: this.$t('orderAuthor.publicOrPrivate'),
						prop: 'canDistribute',
						type: 'tag',
						columnValue: (row) => { return this.$ConstSelect.translate(row.canDistribute, 'PermissionUseList'); },
						tagType: (row) => {
							switch (row.canDistribute) {
							case true: return 'success';
							case false: return 'danger';
							}
						}
					},
					{
						title: this.$t('orderAuthor.permanenceOrNot'),
						prop: 'forever',
						type: 'tag',
						columnValue: (row) => { return this.$ConstSelect.translate(row.forever, 'Whether'); },
						tagType: (row) => {
							switch (row.forever) {
							case true: return 'success';
							case false: return 'danger';
							}
						}
					},
					{
						title: this.$t('orderAuthor.startTime'),
						prop: 'startTime',
						type: 'formatter',
						formatter: this.formatterDate

					},
					{
						title: this.$t('orderAuthor.endTime'),
						prop: 'endTime',
						type: 'formatter',
						formatter: this.formatterDate
					},
					{
						type: 'button',
						title: this.$t('global.operate'),
						width: '200',
						hide: (row) => { return this.$store.state.user.roles.indexOf(superAdmin) < 0; },
						buttons: [
						]
					}
				],
				actions: [
				]
			}
		};
	},

	mounted() {
		this.loadInitData();
	},
	methods: {
		loadInitData() {

		},
		formatterDate(row, porpInfo) {
			return row[porpInfo.property];
		},
		queryFunction(params) {
			return listPackagePermission(params);
		},
		reloadTable() {
			if (this.queryList && this.queryList.reload) {
				this.queryList.reload();
			}
		}
	}
};
</script>
