<template>
	<div class="pricemoitorrecordDetail">
		<a-table :dataSource="tableData" :columns="tableColumns">
			<template #bodyCell="{ column, record, index }">
				<template v-if="column.key === 'locationSwitch'">
					<a-switch v-model:checked="record['locationSwitch']"
						@change="(ev) => onChangeRowPosSwitch(ev, record)"></a-switch>
				</template>
			</template>
		</a-table>
	</div>
</template>
<script setup name="pricemoitorrecordDetail">
import priceMoitorRecordApi from '@/api/basic.info/priceMoitorRecordApi'
import { useRoute, useRouter } from 'vue-router'

const route = useRoute()
const router = useRouter()
const tableColumns = [
	{ title: '操作人', dataIndex: 'updateUser' },
	{ title: '操作日期', dataIndex: 'updateTime' },
	{ title: '操作开关', key: 'locationSwitch' }
]
const tableData = ref([])

const getDetailFrom = () => {
	priceMoitorRecordApi.detailFrom({
		id: route.query.id,
		priceMonitorId: route.query.priceMonitorId,
	}).then((res) => {
		if (res && res.length > 0) {
			tableData.value = res.map(item => {
				return {
					...item,
					locationSwitch: item.locationSwitch === 1 ? true : false
				}
			})
		}
	})
}
onMounted(() => {
	getDetailFrom()
})
</script>
