<template>
	<div class="padding-sm">
		<el-form label-position="right" label-width="120px">
			<el-form-item label="NTP校时：">
				<el-checkbox v-model="ntpTimeInfo.ntp">NTP校时</el-checkbox>
			</el-form-item>
			<el-form-item label="">
				<el-date-picker
				  :disabled="ntpTimeInfo.ntp"
				  type="datetime"
				  placeholder="请输入自定义时间"
				  v-model="ntpTimeInfo.boxTime"
				  style="width: 400px;"
				>
				</el-date-picker>
				<el-button class="margin-left" type="primary" @click="conFirm">确定</el-button>
			</el-form-item>
		</el-form>
	</div>
</template>

<script setup>
	import IpInput from "@/views/components/IpInput/index";
	import { getNtpTime, setNtpTime } from "@/api/settConfiguration"
	const { proxy } = getCurrentInstance();
	const baseUrl = location.protocol+"//"+window.location.host+"/";
	// const baseUrl = import.meta.env.VITE_APP_BASE_API;
	const data = reactive({
		ntpTimeInfo: {}
	});
	const { ntpTimeInfo } = toRefs(data);
	const conFirm = function(){
		proxy.$modal.confirm('确认是否修改NTP时间配置？')
		.then(function () {
			setNtpTime(ntpTimeInfo.value).then((response) => {
				if(response.code == 200){
					getNtpTimeInfo();
					proxy.$modal.msgSuccess("操作成功！");
				}
			})
		}).catch(() => { 
			
		});
	}
	
	const getNtpTimeInfo = function(){
		getNtpTime().then((response) => {
			if(response.code == 200){
				let obj = response.data[1];
				obj.ntp = JSON.parse(obj.ntp);
				ntpTimeInfo.value = obj;
			}
		})
	}
	getNtpTimeInfo();
	
</script>

<style>  
</style>