<template>
	<div>
		<avue-form
			ref="formData"
			:option="option"
			v-model="formData"
		>
			<template #menu-form>
				<el-button icon="el-icon-circle-plus" type="primary" @click="submitForm">保 存</el-button>
				<el-button icon="el-icon-circle-close" @click="cancel">取消</el-button>
			</template>
		</avue-form>
	</div>
</template>

<script>
	import {settlement} from "@/api/order/order";
	export default {
		props:{
			obj:{
				type:Object,
				default:{}
			}
		},
		data (){
			return {
				formData:{},
				option:{
					labelWidth:100,
					menuPosition:'right',
					gutter:10,
					submitBtn:false,
					emptyBtn:false,
					menuBtn:true,
					column:[
						{
							label:'结算金额(元)',
							prop: 'settleAmount',
							span:24,
							type: 'number',
							controls: false,
							precision: 2,
						},
						{
							label:'结算备注',
							prop: 'remarks',
							span:24,
							type: 'textarea',
						}
					]
				}
			}
		},
		methods:{
			cancel(){
				this.$emit('childSubmit','cancel');
			},
			submitForm(){
				let operationOrderSettleEntity = {
					orderId:this.obj.id,
					"settleAmount": this.formData.settleAmount,
					"remarks": this.formData.remarks,
				}
				// console.log("operationOrderSettleEntity",operationOrderSettleEntity);
				// return
				this.$refs['formData'].validate((valid,done) => {
					if (valid) {
						settlement(operationOrderSettleEntity).then(res=>{
							this.$message({
								type: 'success',
								message: '操作成功!',
							});
							this.$emit('childSubmit');
						});
						done()
					} else {
						console.log('error submit!!');
						return false;
					}
				})
			},
		}
	}
</script>

<style>
</style>