<template>
	<a-card title="修改密码">
		<a-form :model="createForm"  layout="vertical">
			<a-row gutter="20">
				<a-col span="12">
					<a-row>
						<a-col span="24">
							<a-form-item required label="旧密码" name="old_password">
								<a-input v-model:value="createForm.old_password" placeholder="请输入旧密码" size="large"/>
							</a-form-item>
						</a-col>
						<a-col span="24">
							<a-form-item required label="新密码" name="new_password">
								<a-input v-model:value="createForm.new_password" placeholder="请输入新密码" size="large"/>
							</a-form-item>
						</a-col>
						<a-col span="24">
							<a-form-item required label="确认密码" name="comform_password">
								<a-input v-model:value="createForm.comform_password" placeholder="请输入确认密码" size="large"/>
							</a-form-item>
						</a-col>
						<a-col span="24">
							<a-form-item label="">
								<a-button type="primary" block @click="saveForm" size="large">保存</a-button>
							</a-form-item>
						</a-col>
					</a-row>
				</a-col>
			</a-row>
		</a-form>
	</a-card>
	
</template>

<script setup lang="ts">
	import { ref, onMounted, computed } from 'vue';
	import { PostCompanyPwdEdit } from '@/apis/models';
	import { warnToast, successToast } from '@/utils/toastHelper';
	let createForm : companyListType.addrFormType = ref({
		old_password: '',
		new_password: '',
		comform_password: ''
	})
	const saveForm = () => {
		if(createForm.value.new_password != createForm.value.comform_password) {
			warnToast('新密码和确认密码不一致')
			return false;
		}
		PostCompanyPwdEdit(createForm.value).then(res => {
			successToast('修改成功,请重新登录')
			resetForm()
		})
	}
	
	const resetForm = () => {
		createForm.value = {
			old_password: '',
			new_password: '',
			comform_password: ''
		}
	}
	
	
</script>

<style scoped lang="less">
	
</style>