// import { onMounted, ref, onBeforeUnmount, computed, reactive } from 'vue'
import { enumMaplistStore } from '@/store'

export function enumMap () {
	const StoreDEl = enumMaplistStore()
	const { enumMap, parentMap } = StoreDEl.enumMaplist
	const cocName = (id = '') => {
		const name = enumMap[id]
		return name
	}
	const cocID = (id) => {
		const name = enumMap[id]
		return id
	}
	const getEnumByEnumCode = (enumCode) => {
		for (const key of Object.keys(parentMap)) {
			const arr = parentMap[key]
			for (const enumData of arr) {
				if (enumData.enumid == enumCode) {
					// console.log(enumData)
					if (!enumData.enumname) return console.log('取不到')
					// console.log(enumData.enumname)
					return enumData.enumname
				}
			}
		}
		console.warn('没有找到 enum code', enumCode)
		return null
	}
	const getEnumListByEnumId = (enumId) => {
		return parentMap[enumId]
	}

	const YES_NO_3 = [
		{ value: '1', label: '能' },
		{ value: '0', label: '否' },
		{ value: '9', label: '其他或不确定' }
	]

	const cocDEl = (id) => {
		for (const item of YES_NO_3) {
			if (item.value == id) return item.label
		}
	}

	const LEVEL_TYPE_3 = [
		{ value: '1', label: 'Ⅰ级' },
		{ value: '2', label: 'Ⅱ级' },
		{ value: '3', label: 'Ⅲ级' },
		{ value: '4', label: 'Ⅳ级' }
	]

	const cocDElⅣ = (id) => {
		for (const item of LEVEL_TYPE_3) {
			if (item.value == id) return item.label
		}
	}

	const LEVEL_TYPE_5 = [
		{ value: '1', label: 'Ⅰ级' },
		{ value: '2', label: 'Ⅱ级' },
		{ value: '3', label: 'Ⅲ级' },
		{ value: '4', label: '无粮情检测技术' }
	]

	const cocDElⅣV = (id) => {
		for (const item of LEVEL_TYPE_5) {
			if (item.value == id) return item.label
		}
	}

	const TFXTXS = [
		{ value: '0', label: '竖向通风' },
		{ value: '1', label: '横向通风' },
		{ value: '2', label: '径向通风' },
		{ value: '3', label: '全网板通风' },
		{ value: '4', label: '其它' }
	]

	const cocTFXTXS = (id) => {
		for (const item of TFXTXS) {
			if (item.value == id) return item.label
		}
	}
	const DLMXS = [
		{ value: '01', label: '“一字型”挡粮板' },
		{ value: '02', label: '“三角形”挡粮门' },
		{ value: '03', label: '“弧形”挡粮门' },
		{ value: '04', label: '围包' },
		{ value: '05', label: '其它型式' }
	]
	const cocDLMXS = (id) => {
		for (const item of DLMXS) {
			if (item.value == id) return item.label
		}
	}

	const BUG_INSPECTION_TYPE = [
		{ value: '01', label: '远程检测预警' },
		{ value: '02', label: '人工手动筛查' },
		{ value: '03', label: '其它' }
	]
	const cocBUG_INSPECTION_TYPE = (id) => {
		for (const item of BUG_INSPECTION_TYPE) {
			if (item.value == id) return item.label
		}
	}
	return { cocName, getEnumByEnumCode, cocDEl, cocDElⅣ, cocDElⅣV, cocTFXTXS, cocDLMXS, cocBUG_INSPECTION_TYPE }
}
