<template>
	<!-- 位置信息管理 -->
	<div class="pricemoitorrecord">
		<a-card :bordered="false">
			<a-space class="search">
				<div class="silt-title">
					<span style="width: 120px; margin-right: 8px; text-align: right; display: block; line-height: 30px">{{
						'维修设备总数：'
					}}</span>
					<h3 style="width: 220px">{{ pagelist.wxsbzs }}</h3>
				</div>
				<div class="silt-title">
					<span style="width: 120px; margin-right: 8px; text-align: right; display: block; line-height: 30px">{{
						'维修中设备数量：'
					}}</span>
					<h3 style="width: 220px">{{ pagelist.wxzsbsl }}</h3>
				</div>
				<div class="silt-title">
					<span style="width: 120px; margin-right: 8px; text-align: right; display: block; line-height: 30px">{{
						'数据处理条数：'
					}}</span>
					<h3 style="width: 220px">{{ pagelist.sjclts }}</h3>
				</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 == 'acc'">
						<div>粮食设备</div>
					</template>

					<template v-if="column.dataIndex == 'handleStatus'">
						<div v-if="record.handleStatus == 0">未申请</div>
						<div v-if="record.handleStatus == 1">已申请</div>
						<div v-if="record.handleStatus == 2">已处理</div>
					</template>
					<template v-if="column.key === '操作'">
						<a-button type="link" @click="onView('view', record)">查看</a-button>
						<a-button type="link" v-if="record.handleStatus == 1" @click="CHULI(record)">处理</a-button>
					</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, onMounted } 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: 'orgName' },
		{ title: '设备名称', align: 'center', dataIndex: 'deviceName' },
		{ title: '设备类型', align: 'center', dataIndex: 'acc' },
		{ title: '维修开始时间', align: 'center', dataIndex: 'repairStart' },
		{ title: '维修结束时间', align: 'center', dataIndex: 'repairEnd' },
		{ title: '维修人', align: 'center', dataIndex: 'repairer' },
		{ title: '处理状态', align: 'center', dataIndex: 'handleStatus' },
		{ title: '操作', width: '20%', align: 'center', key: '操作' }
	]

	onMounted(() => {
		listpage()
	})

	const pagelist = ref({})
	const listpage = async () => {
		const res = await business.WBBAlnumber()
		pagelist.value = res
	}

	const CHULI = async (v) => {
		const res = await business.WBBAlupdateById({
			id: v.id,
			handleStatus: 2
		})
		onSearch({ current: pagination.current, size: pagination.pageSize })
	}

	const { DEl, change, tableData, onSearch, handlePageChange, pagination, Search, onReset, SearchFormDel } =
		listPagination({ dwmc: '' }, business.WBBAlist, {}, { 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>
