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

<script>
import { updateRegion } from '@/api/areavisual/region';
export default {
	props: {
		injectData: {
			type: Object,
			default: () => ({}),
		},
	},
	data() {
		return {};
	},
	created() {},
	methods: {
		changeStatus(val) {
			const pdata = { ...this.injectData, regionState: val };
			this.$confirm(
				`是否确认修改${'区域  [ ' + this.injectData.regionName + ' ]  '}的状态?`,
				'更新状态',
				{
					confirmButtonText: '确认修改',
					cancelButtonText: '取消',
					type: 'warning',
				}
			)
				.then(() => {
					updateRegion(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>
