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

<script>
import { getCacheList, delCacheList } from '@/api/management/user';

export default {
	name: 'CacheControl',
	components: {
	},
	data() {
		return {
			pagerConfig: {
				pageSize: 'pageSize',
				pageIndex: 'pageNum'
			},
			queryForm: {
				labelWidth: '80px',
				reset: true,
				queryObject: {
					key: {
						type: 'text',
						label: 'key'
					}
				}

			},
			queryList: {
				query: this.queryFunction,
				selectCheckShow: false,
				indexShow: true,
				columns: [
					{
						title: 'key',
						prop: 'key'
					},
					{
						type: 'button',
						title: this.$t('global.operate'),
						width: '250',
						buttons: [
							{
								name: this.$t('global.delete'),
								handleClick: this.handledelete,
								type: 'danger'
							}
						]
					}
				]
			},
			currentModel: {}
		};
	},
	created() {
	},
	methods: {
		// 删除
		handledelete(index, row) {
			this.$confirm( this.$t('tip.deleteListHint'), this.$t('global.tips'), {
				confirmButtonText: this.$t('global.confirm'),
				cancelButtonText: this.$t('global.cancel'),
				type: 'warning'
			}).then(() => {
				delCacheList(row.key).then(response => {
					this.$message.success(this.$t('tip.successfullyDelete'));
					this.reloadTable();
				}).catch(() => {
					this.$messageBox(this.$t('tip.failDelete'));
				});
			});
		},
		queryFunction(params) {
			return getCacheList(params);
		},
		reloadTable() {
			this.queryList.reload();
		}
	}
};
</script>
