import { tools } from 'hq-tools';

export const dict = {
	cellRendererFramework: 'DictCell'
};

export const number = {
	valueFormatter: params => {
		let format = params.colDef.cellRendererParams ? params.colDef.cellRendererParams.format : null;
		return (format && params.value) ? tools.partition(params.value, format) : params.value;
	},
	filter: 'number'
};
export const string = {

};
export const image = {
	cellRendererFramework: 'ImageCell'
};
export const qrcode = {
	cellRendererFramework: 'QrcodeCell'
};
export const datetime = {
	valueFormatter: params => {
		return new Date(params.value) == 'Invalid Date' ? params.value : tools.dateFormat(params.value, 'yyyy-MM-dd HH:mm:ss');;
	}
};
export const date = {
	valueFormatter: params => {
		return new Date(params.value) == 'Invalid Date' ? params.value : tools.dateFormat(params.value, 'yyyy-MM-dd');
	},
	tooltipValueGetter: value => {
		return tools.dateFormat(value, 'yyyy-MM-dd', 'yyyy-MM-dd HH:mm:ss');
	}
};
export const boolean = {
	valueFormatter: params => (!params.value ? '《无》' : ['1', true].includes(params.value) ? '是' : '否'),
	cellRendererFramework: 'BooleanCell'
};
export const button = {
	cellRendererFramework: 'ButtonCell',
	filter: false,
	print: false
};
export const asyncTrans = {
	cellRendererFramework: 'DictCell'
};
export default {
	dict,
	number,
	string,
	image,
	qrcode,
	datetime,
	date,
	boolean,
	button,
	asyncTrans
};
