function isMainContractFieldsComplete(form) {
	var contractCode = (form.contractCode || '').trim();
	if (!contractCode) return false;
	if (!form.lessorId) return false;
	if (!form.customerId) return false;

	var mileage = form.mileage || {};
	if (mileage.hasRequirement) {
		if (!mileage.period) return false;
		if (mileage.targetKm == null || mileage.targetKm === '') return false;
	}

	var feeInfo = form.feeInfo || {};
	if (feeInfo.paymentPeriod == null || feeInfo.paymentPeriod === '') return false;
	if (!feeInfo.hydrogenPaymentMethod) return false;

	if (feeInfo.hydrogenPaymentMethod === 'prepay') {
		if (feeInfo.prepayAmount == null || feeInfo.prepayAmount === '') return false;
		if (feeInfo.payAheadWorkdays == null || feeInfo.payAheadWorkdays === '') return false;
	}

	if (feeInfo.returnHydrogenDiffUnitPrice == null || feeInfo.returnHydrogenDiffUnitPrice === '') {
		return false;
	}

	return true;
}

/** 主体合同信息卡片完成度 */
export function isMainContractFormComplete(form) {
	return isMainContractFieldsComplete(form);
}

/** 附件1：租赁订单卡片完成度 */
export function isLeaseOrderFormComplete(form) {
	var leaseOrder = form.leaseOrder || {};
	if (leaseOrder.thirdPartyLiabilityMillion == null || leaseOrder.thirdPartyLiabilityMillion === '') {
		return false;
	}
	return true;
}

/** 授权委托书卡片完成度 */
export function isPowerOfAttorneyFormComplete(form) {
	var delegates = (form.powerOfAttorney && form.powerOfAttorney.delegates) || [];
	if (!delegates.length) return false;
	return delegates.every(function (row) {
		return Boolean((row.name || '').trim())
			&& Boolean((row.contact || '').trim())
			&& Boolean((row.idNumber || '').trim());
	});
}

/** 判断新增租赁合同左侧表单必填项是否均已填写 */
export function isLeaseContractFormComplete(form) {
	return isMainContractFieldsComplete(form)
		&& isLeaseOrderFormComplete(form)
		&& isPowerOfAttorneyFormComplete(form);
}
