<template>
	<!-- 位置信息管理 -->
	<div class="pricemoitorrecord">
		<a-card :bordered="false">
			<a-space class="search">
				<div class="silt-title">
					<span style="width: 70px; margin-right: 8px; text-align: right; display: block; line-height: 30px">{{
						'设备类型'
					}}</span>
					<a-select style="width: 220px" v-model:value="SearchFormDel.equipmentType">
						<a-select-option :value="1">消防水箱</a-select-option>
						<a-select-option :value="2">消防水池</a-select-option>
					</a-select>
				</div>
				<div class="btnBox">
					<a-button type="primary" class="primarySele" @click="Search"> 查询 </a-button>
					<a-button class="snowy-buttom-left primarySele" @click="onReset"> 重置 </a-button>
					<a-button type="primary" class="primarySele" @click="onView('add', {})"> 新增 </a-button>
				</div>
			</a-space>
		</a-card>

		<div class="list" style="margin-top: 10px">
			<a-table :dataSource="tableData" :pagination="pagination" :columns="tableColumns">
				<template #bodyCell="{ column, record }">
					<template v-if="column.dataIndex == 'equipmentType'">
						<div v-if="record.equipmentType == 1">消防水箱</div>
						<div v-if="record.equipmentType == 2">消防水池</div>
					</template>
					<template v-if="column.key === '操作'">
						<a-button type="link" @click="onView('view', record)">查看</a-button>
						<a-button type="link" @click="onView('edit', record)">编辑</a-button>
						<a-popconfirm title="确定要删除吗？" @confirm="onView('del', record)">
							<a-button type="link">删除</a-button>
						</a-popconfirm>
					</template>
				</template>
			</a-table>
		</div>
	</div>
	<Form ref="formRef" @successful="tableRef.refresh()" @change="change" />
</template>
<script setup>
	import business from '@/api/security/index.js'
	import { listPagination } from '@/hook/listlistPagination.js'
	import Form from './form.vue'

	import { reactive, ref } from 'vue'
	import { useRouter } from 'vue-router'
	import { defineComponent } from 'vue'
	const formRef = ref(null)
	const router = useRouter()
	const tableColumns = [
		{
			title: '序号',
			dataIndex: 'Index',
			align: 'center',
			width: '5%',
			customRender: ({ text, record, index }) => {
				return `${index + 1}`
			}
		},
		{ title: '设备类型', align: 'center', dataIndex: 'equipmentType' },
		{ title: '预警阈值', align: 'center', dataIndex: 'warningThreshold' },
		{ title: '维护人', align: 'center', dataIndex: 'maintenancePerson' },
		{ title: '维护时间', align: 'center', dataIndex: 'maintenanceTime' },
		{ title: '操作', width: '20%', align: 'center', key: '操作' }
	]
	const { DEl, change, tableData, onSearch, handlePageChange, pagination, Search, onReset, SearchFormDel } =
		listPagination({ equipmentType: '' }, business.YZSZedit, business.YZSZDELdelete, { sortOrder: 'ASCEND' })
	// 查看表单数据
	const onView = (record, row) => {
		switch (record) {
			case 'add':
				formRef.value.onOpen(record, true, false)
				break
			case 'del':
				DEl(row)
				break
			case 'view':
				formRef.value.onOpen(record, true, true, row)
				break
			case 'edit':
				formRef.value.onOpen(record, true, false, row)
				break
			default:
				// router.push('/business/personnelDel')
				break
		}
	}
</script>
<style lang="less" scoped>
	.search {
		padding-top: 20px;
		padding-left: 50px;
		margin-bottom: 32px;
		.btnBox {
			width: 100%;
			display: inline-block;
			display: flex;
			justify-content: space-around;
			align-items: center;
			.primarySele {
				margin-left: 20px;
				margin-right: 20px;
			}
		}
	}
	.silt-title {
		display: flex;
	}
</style>
