<!--
 * @Author: zwq
 * @Date: 2025-10-11 14:41:12
 * @LastEditors: zwq
 * @LastEditTime: 2026-01-14 14:15:47
 * @Description:
-->
<template>
	<el-switch
		@change="changeStatus"
		size="small"
		v-model="injectData.laneState"
		:active-value="1"
		:inactive-value="2"></el-switch>
</template>

<script>
import { updateLane } from '@/api/areavisual/lane';
export default {
	props: {
		injectData: {
			type: Object,
			default: () => ({}),
		},
	},
	data() {
		return {};
	},
	created() {},
	methods: {
		changeStatus(val) {
			const pdata = { ...this.injectData, laneState: val };
			this.$confirm(
				`是否确认修改${'巷道  [ ' + this.injectData.laneName + ' ]  '}的状态?`,
				'更新状态',
				{
					confirmButtonText: '确认修改',
					cancelButtonText: '取消',
					type: 'warning',
				}
			)
				.then(() => {
					updateLane(pdata).then((res) => {
						if (res.code === 0 || res.code === 200) {
							this.$modal.msgSuccess('修改成功');
							this.$emit('emitData');
						} else {
							this.$modal.msg(res.msg);
						}
					});
				})
				.catch((res) => {
					this.$emit('emitData');
					this.$message({
						type: 'info',
						message: '已取消',
					});
				});
		},
	},
};
</script>
