
<template>
	<span>{{value}}</span>
</template>

<script>
export default {
	name: 'dict-cell',
	computed: {
		colDef() {
			return this.params.colDef
		},
		gridDicts() {
			return this.params.context.gridDicts;
		},
		dicts() {
			return this.params.context.dicts;
		},
		dict() {
			let dictObj = {};
			if (this.colDef && this.colDef.cellRendererParams && this.colDef.cellRendererParams.dict && this.colDef.cellRendererParams.dict instanceof Object) {
				dictObj = Object.assign(dictObj, this.colDef.cellRendererParams.dict)
			} else if (this.colDef && this.colDef.cellRendererParams && this.colDef.cellRendererParams.dict && this.colDef.cellRendererParams.dict instanceof Map) {
				for (let [key, value] of this.colDef.cellRendererParams.dict) {
					dictObj[key] = value;
				}
			} else if (this.colDef && this.colDef.cellRendererParams
				&& this.colDef.cellRendererParams.dict && typeof this.colDef.cellRendererParams.dict === 'string'
				&& this.dicts[this.colDef.cellRendererParams.dict]) {
				dictObj = Object.assign(dictObj, this.dicts[this.colDef.cellRendererParams.dict]);
			} else if (this.colDef && this.colDef.cellRendererParams &&
				(this.colDef.cellRendererParams.asyncTranslate || this.colDef.cellRendererParams.asyncTranslateByPager)
				&& this.gridDicts[this.colDef.colId]) {
				dictObj = Object.assign(dictObj, this.gridDicts[this.colDef.colId])
			}
			return dictObj
		},
		value() {
			return this.dict[this.params.value] ? this.dict[this.params.value] : this.params.value
		}
	},
	data() {

	},
	beforeMount() {
		// console.log(this.params.context);
		// this.column = this.params.colDef;
	},
}
</script>