package com.gx.obe.evaluation.step.dialog;

import java.text.MessageFormat;

import org.apache.commons.lang.StringUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.core.CallBack;
import org.eclipse.swt.core.MessageDialog;
import org.eclipse.swt.core.widgets.EButton;
import org.eclipse.swt.core.widgets.EDialog;
import org.eclipse.swt.core.widgets.ELink;
import org.eclipse.swt.core.widgets.ESepator;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import com.gx.obe.ColorConstants;
import com.gx.obe.common.icons.IconsActivator;
import com.gx.obe.components.core.enumeration.EvaluationStepEnum;
import com.gx.obe.components.core.enumeration.TenderProjectEnum;
import com.gx.obe.evaluation.step.listener.BidRegulationsListener;
import com.gx.obe.message.Messages;
import com.gx.obe.util.utils.LogUtils;
import com.gx.obe.util.utils.ObjectUtils;
import com.gx.obe.web.entity.Supplier;
import com.gx.obe.web.entity.SupplierEvaluationResult;
import com.gx.obe.web.entity.auth.AuthUser;
import com.gx.obe.web.entity.expert.ExpertEvaluationResult;
import com.gx.obe.web.entity.tender.TenderProjectEntity;
import com.gx.obe.web.service.SupplierEvaluationResultService;
import com.swtdesigner.ResourceManager;
import com.swtdesigner.SWTResourceManager;

/**
 * @Description: 录入评审、废标（否决）意见
 * @author guoyr
 */
public class EvaluationOpinionDialog extends EDialog {
	private ExpertEvaluationResult expertEvaluationResult;
	private SupplierEvaluationResultService supplierEvaluationResultService;
	private Composite evaluateGroup;
	private Text supplierEvalOpinionText;
//	private EButton saveBtn;
	private TenderProjectEntity tenderProject;
	private Supplier supplier;
	private AuthUser curUser;
	private Text requirementText;
	private Label requirementLength;
	private Label opinionLength;
	private ELink wasteBidItemLink;
	private ELink refreshLink;
	private StyledText editorLabel;
	private boolean applyFlag;
	private boolean isUnqualified = false;
	private SupplierEvaluationResult supplierEvaluationResult;
	private EButton submitBtn;
	private Label openionTitleLabel;
	private Combo combo;
	private CallBack callBack;
	{
		LogUtils.logClass(EvaluationOpinionDialog.class);
	}
	
	/**
	 * @param parentShell
	 * @param tenderProjectEntity
	 * @param supplier
	 * @param evaluationFactor
	 * @param expertEvaluationResult
	 * @param evalFactorResult
	 * @param callBack
	 */
	public EvaluationOpinionDialog(Shell parentShell, TenderProjectEntity tenderProject, Supplier supplier, AuthUser curUser, ExpertEvaluationResult expertEvaluationResult) {
		super(parentShell);
		setTitle(supplier.getSupplierName());
		this.tenderProject = tenderProject;
		this.supplier = supplier;
		this.curUser = curUser;
		this.expertEvaluationResult = expertEvaluationResult;
		supplierEvaluationResultService = new SupplierEvaluationResultService();
		
	}
	
	public EvaluationOpinionDialog(Shell parentShell, TenderProjectEntity tenderProject, Supplier supplier, AuthUser curUser, ExpertEvaluationResult expertEvaluationResult,CallBack callBack) {
		super(parentShell);
		setTitle(supplier.getSupplierName());
		this.tenderProject = tenderProject;
		this.supplier = supplier;
		this.curUser = curUser;
		this.expertEvaluationResult = expertEvaluationResult;
		supplierEvaluationResultService = new SupplierEvaluationResultService();
		this.callBack=callBack;
	}

	/** 
	 * @Description: 
	 * @param parent
	 * @return
	 */
	@Override
	protected Control createDialogArea(Composite parent) {
		Composite top = (Composite) super.createDialogArea(parent);
		GridLayout gl_top = new GridLayout(1, false);
		gl_top.verticalSpacing = 0;
		gl_top.horizontalSpacing = 0;
		gl_top.marginHeight = 0;
		gl_top.marginWidth = 0;
		top.setLayout(gl_top);
		
		Composite container = new Composite(top, SWT.NONE);
		container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		GridLayout gl_container = new GridLayout(1, false);
		container.setLayout(gl_container);
		
		evaluateGroup = new Composite(container, SWT.NONE);
		evaluateGroup.setFont(SWTResourceManager.getFont("宋体", 9, SWT.BOLD));
		GridLayout gl_evaluateGroup = new GridLayout(1, false);
		evaluateGroup.setLayout(gl_evaluateGroup);
		evaluateGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		Composite composite_5 = new Composite(evaluateGroup, SWT.NONE);
		composite_5.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
		composite_5.setLayout(new GridLayout(3, false));
		
		editorLabel = new StyledText(composite_5, SWT.WRAP);
		editorLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
		editorLabel.setFont(SWTResourceManager.getFont("微软雅黑", 10, SWT.NORMAL));
		editorLabel.setForeground(ColorConstants.FONT_BLACK_COLOR);
		editorLabel.setText("您正在对["+ supplier.getSupplierName() +"]录入评（废）标意见");
		
		refreshLink = new ELink(composite_5, SWT.NONE);
		refreshLink.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/edit.png"));
		refreshLink.setText(Messages.Button_ApplyInput);
		new Label(composite_5, SWT.NONE);
		refreshLink.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				refreshAction();
			}
		});
		
		Composite composite_3 = new Composite(evaluateGroup, SWT.NONE);
		GridData gd_composite_3 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
		gd_composite_3.heightHint = 50;
		composite_3.setLayoutData(gd_composite_3);
		GridLayout gl_composite_3 = new GridLayout(1, false);
		gl_composite_3.verticalSpacing = 1;
		gl_composite_3.horizontalSpacing = 1;
		gl_composite_3.marginHeight = 1;
		gl_composite_3.marginWidth = 1;
		composite_3.setLayout(gl_composite_3);
		composite_3.setBackground(ColorConstants.BORDER_LINE_COLOR);
		Composite composite_1 = new Composite(composite_3, SWT.NONE);
		composite_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
		composite_1.setLayout(new GridLayout(3, false));
		
		Label label_2 = new Label(composite_1, SWT.NONE);
		label_2.setFont(SWTResourceManager.getFont("微软雅黑", 10, SWT.BOLD));
		label_2.setForeground(ColorConstants.FONT_BLACK_COLOR);
		label_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		label_2.setText(Messages.Title_biddingFileRequir + "("+Messages.Required+")");
		
		requirementLength = new Label(composite_1, SWT.NONE);
		requirementLength.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		requirementLength.setForeground(ColorConstants.NOTE_TIPS_COLOR);
		requirementLength.setText("");
		
		wasteBidItemLink = new ELink(composite_1, SWT.NONE);
		wasteBidItemLink.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				selectionWasteOpinion();
			}
		});
		wasteBidItemLink.setText(MessageFormat.format(Messages.Button_selectFormat, Messages.Button_votoClause));
		wasteBidItemLink.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/query.png"));
		
//		ESepator req_sep = new ESepator(composite_3, SWT.NONE);
//		req_sep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
//		req_sep.setBackground(ColorConstants.BORDER_LINE_COLOR);
//		req_sep.setLineStyle(SWT.LINE_DOT);
//		req_sep.setLineWidth(2);
		
		requirementText = new Text(composite_3, SWT.V_SCROLL | SWT.MULTI | SWT.WRAP);
		requirementText.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		requirementText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		requirementText.setTextLimit(500);
		
		Composite composite_2 = new Composite(evaluateGroup, SWT.NONE);
		GridData gd_composite_2 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
		gd_composite_2.heightHint = 50;
		composite_2.setLayoutData(gd_composite_2);
		GridLayout gl_composite_2 = new GridLayout(1, false);
		gl_composite_2.verticalSpacing = 1;
		gl_composite_2.horizontalSpacing = 1;
		gl_composite_2.marginHeight = 1;
		gl_composite_2.marginWidth = 1;
		composite_2.setLayout(gl_composite_2);
		composite_2.setBackground(ColorConstants.BORDER_LINE_COLOR);
		Composite composite_4 = new Composite(composite_2, SWT.NONE);
		composite_4.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		GridData gd_composite_4 = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
		gd_composite_4.heightHint = 35;
		composite_4.setLayoutData(gd_composite_4);
		composite_4.setLayout(new GridLayout(3, false));
		
		openionTitleLabel = new Label(composite_4, SWT.NONE);
		openionTitleLabel.setFont(SWTResourceManager.getFont("微软雅黑", 10, SWT.BOLD));
		openionTitleLabel.setForeground(ColorConstants.FONT_BLACK_COLOR);
		openionTitleLabel.setText("评（废）标意见");
		
		opinionLength = new Label(composite_4, SWT.NONE);
		GridData gd_opinionLength = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
		gd_opinionLength.widthHint = 305;
		opinionLength.setLayoutData(gd_opinionLength);
		opinionLength.setForeground(ColorConstants.NOTE_TIPS_COLOR);
		opinionLength.setText("");
		new Label(composite_4, SWT.NONE);
		
//		ESepator opi_sep = new ESepator(composite_2, SWT.NONE);
//		opi_sep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
//		opi_sep.setBackground(ColorConstants.BORDER_LINE_COLOR);
//		opi_sep.setLineStyle(SWT.LINE_DOT);
//		opi_sep.setLineWidth(2);
		
		supplierEvalOpinionText = new Text(composite_2, SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
		supplierEvalOpinionText.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		supplierEvalOpinionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		supplierEvalOpinionText.setTextLimit(500);
		
		Composite composite_6 = new Composite(evaluateGroup, SWT.NONE);
		composite_6.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		composite_6.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
		GridLayout gl_composite_6 = new GridLayout(2, false);
		composite_6.setLayout(gl_composite_6);
		
		Label label = new Label(composite_6, SWT.NONE);
		label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		label.setFont(SWTResourceManager.getFont("微软雅黑", 11, SWT.BOLD));
		label.setForeground(ColorConstants.FONT_BLACK_COLOR);
		label.setText("否决投标类别(必填)");

		combo = new Combo(composite_6, SWT.READ_ONLY);
		combo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
		
		ESepator label_7 = new ESepator(top, SWT.SEPARATOR | SWT.HORIZONTAL);
		label_7.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		label_7.setBackground(ColorConstants.SEP_LIGHT_COLOR);
		
		Composite composite = new Composite(top, SWT.NONE);
		composite.setBackgroundMode(SWT.INHERIT_FORCE);
		composite.setBackgroundImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/fill_bg.png"));
		composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		GridLayout gl_composite = new GridLayout(3, false);
		composite.setLayout(gl_composite);
		
//		saveBtn = new EButton(composite, SWT.NONE);
//		saveBtn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/save.png"));
//		saveBtn.addMouseListener(new MouseAdapter() {
//			@Override
//			public void mouseUp(MouseEvent e) {
//				saveEvaluationAction(false);
//			}
//		});
//		GridData gd_confirmBtn = new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1);
//		gd_confirmBtn.widthHint = 90;
//		saveBtn.setLayoutData(gd_confirmBtn);
//		saveBtn.setText(Messages.Button_save);
		
		submitBtn = new EButton(composite, SWT.NONE);
		submitBtn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/submit.png"));
		submitBtn.setMinWidth(90);
		submitBtn.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				saveEvaluationAction(true);
			}
		});
		submitBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
		submitBtn.setText(Messages.Button_save);
		
		EButton cancel_btn = new EButton(composite, SWT.NONE);
		cancel_btn.setMinWidth(90);
		cancel_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/close.png"));
		cancel_btn.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				getShell().close();
			}
		});
		cancel_btn.setText(Messages.Button_close);
		new Label(composite, SWT.NONE);

		init();
		return container;
	}

	/**
	 * @Description: 初始化界面数据
	 * @author guoyr
	 */
	private void init(){
		combo.add("----请选择----", 0);
		combo.add("企业资质", 1);
		combo.add("业绩要求", 2);
		combo.add("人员资质", 3);
		combo.add("服务器/工期/供货期", 4);
		combo.add("实质性响应", 5);
		combo.add("信誉要求", 6);
		combo.add("投标有效期", 7);
		combo.add("投标保证金", 8);
		combo.add("财务要求", 9);
		combo.add("其他原因", 10);
		combo.select(0);
		editorLabel.setEditable(false);
		requirementText.addModifyListener(new ModifyListener() {
			public void modifyText(ModifyEvent arg0) {
				requirementLength.setText("   (" +requirementText.getText().trim().length() + "/500)");
			}
		});
		requirementText.setText("");
		
		supplierEvalOpinionText.addModifyListener(new ModifyListener() {
			public void modifyText(ModifyEvent arg0) {
				opinionLength.setText("   (" +supplierEvalOpinionText.getText().trim().length() + "/500)");
			}
		});
		supplierEvalOpinionText.setText(ObjectUtils.getObjString(expertEvaluationResult.getSupplierOpinion()));
		supplierEvalOpinionText.forceFocus();
		refreshAction();
		String vetoType=null;
		if(supplierEvaluationResult != null && supplierEvaluationResult.getVetoType() != null ) {
		    vetoType = supplierEvaluationResult.getVetoType();
		}
		if (EvaluationStepEnum.ENTERPRISE_QUALIFICATIONS.equals(vetoType)) {
			combo.select(1);
		} else if (EvaluationStepEnum.PERFORMANCE_REQUIREMENTS.equals(vetoType)) {
			combo.select(2);
		} else if (EvaluationStepEnum.PERSONNEL_QUALIFICATIONS.equals(vetoType)) {
			combo.select(3);
		} else if (EvaluationStepEnum.SERVER_DURATION_SUPPLY.equals(vetoType)) {
			combo.select(4);
		} else if (EvaluationStepEnum.SUBSTANTIVE_RESPONSE.equals(vetoType)) {
			combo.select(5);
		} else if (EvaluationStepEnum.REPUTATION_REQUIREMENTS.equals(vetoType)) {
			combo.select(6);
		} else if (EvaluationStepEnum.BID_VALIDITY_PERIOD.equals(vetoType)) {
			combo.select(7);
		} else if (EvaluationStepEnum.BID_BOND.equals(vetoType)) {
			combo.select(8);
		} else if (EvaluationStepEnum.FINANCIAL_REQUIREMENTS.equals(vetoType)) {
			combo.select(9);
		} else if (EvaluationStepEnum.OTHER_REASONS.equals(vetoType)) {
			combo.select(10);
		}
		//refreshAction();
	}
	
	/**
	 * @Description: 刷新供应商评审意见
	 * @author guoyr 
	 */
	private void refreshSupplierEvaluationResult(){
		supplierEvaluationResult = supplierEvaluationResultService.getSupplierEvaluationResultByTenderIdAndSupplierId(tenderProject.getId(), supplier.getId());
		isUnqualified = false;
		String editor = null;
		if(null != supplierEvaluationResult){
			if(null != supplierEvaluationResult.getEvaluationOpinion() && supplierEvaluationResult.getEvaluationOpinion().length() > 0){
				supplierEvalOpinionText.setText(supplierEvaluationResult.getEvaluationOpinion());
			}
			if(null != supplierEvaluationResult.getBiddingRequest() && supplierEvaluationResult.getBiddingRequest().length() > 0){
				requirementText.setText(supplierEvaluationResult.getBiddingRequest());
			}
			editor = supplierEvaluationResult.getOpinionEditor();
			if(null != supplierEvaluationResult.getAccessment() && supplierEvaluationResult.getAccessment().equals(com.gx.obe.components.core.enumeration.EvaluationStepEnum.UNQUALIFIED)){
				isUnqualified = true;
			}
		}
		if(applyFlag){
//			editor = Messages.You;
		}else {
			editor = (null != editor && editor.length() > 0) ? editor : Messages.Others;
		}
		if(!isUnqualified && null != expertEvaluationResult.getAccessment() && expertEvaluationResult.getAccessment().equals(com.gx.obe.components.core.enumeration.EvaluationStepEnum.UNQUALIFIED)){
			isUnqualified = true;
		}
		String opinionStr = isUnqualified ? Messages.Title_bidCancelledOpinion : Messages.Title_evaluationOpinion;
		editorLabel.setText(MessageFormat.format(Messages.Title_supplierEvaluationOpinion, editor, supplier.getSupplierName(), opinionStr));
		if(isUnqualified){
			openionTitleLabel.setText(Messages.Title_bidCancelledOpinion + "("+Messages.Required+")");
//			submitBtn.setText(MessageFormat.format(Messages.Button_saveFormat, Messages.Title_bidCancelledOpinion));
		}else {
			openionTitleLabel.setText(Messages.Title_evaluationOpinion+ "("+Messages.Required+")");
//			submitBtn.setText(MessageFormat.format(Messages.Button_saveFormat, Messages.Title_evaluationOpinion));
		}
		openionTitleLabel.getParent().layout();
//		StyleRange styleRange = new StyleRange(); 
//		styleRange.start = 0; 
//		styleRange.length = editor.length(); 
//		styleRange.foreground = SWTResourceManager.getColor(SWT.COLOR_BLUE);
//		styleRange.fontStyle = SWT.BOLD; 
//		editorLabel.setStyleRange(styleRange);
//		styleRange.start = openionTitleLabel.getText().length() -  supplier.getSupplierName().length(); 
//		styleRange.length = openionTitleLabel.getText().length();
//		editorLabel.setStyleRange(styleRange);
	}
	
	/**
	 * @Description:刷新 
	 * @author guoyr 
	 */
	private void refreshAction(){
		if(refreshLink.getEnabled()){
			applyEditSupplierEvaluationResult();
			refreshSupplierEvaluationResult();
		}
		
	}
	/**
	 * @Description: 申请编辑供应商的评审意见
	 * @author guoyr
	 * @return 
	 */
	private void applyEditSupplierEvaluationResult(){
		applyFlag = supplierEvaluationResultService.applyEditSupplierEvaluationResult(tenderProject.getId(), supplier.getId(), curUser.getId(), curUser.getUserName());
		if(!applyFlag){
			MessageDialog.openShortMessage("申请失败，请稍后再试！");
		}
		refreshLink.setEnabled(!applyFlag);// 已申请到编辑权限就再不用刷新了
		refreshLink.setVisible(!applyFlag);
		wasteBidItemLink.setEnabled(applyFlag);
		requirementText.setEditable(applyFlag);
		supplierEvalOpinionText.setEditable(applyFlag);
//		saveBtn.setEnabled(applyFlag);
		submitBtn.setEnabled(applyFlag);
	}
	
	/**
	 * @Description: 选择废标意见
	 * @author guoyr 
	 */
	private void selectionWasteOpinion(){
		if(applyFlag){
			SelectBidRegulationsDialog dialog = new SelectBidRegulationsDialog(getParentShell(), tenderProject, new BidRegulationsListener() {
				public void selectBidRegulations(String bidRegulationsContents) {
					if(requirementText.getText().length() > 0){
						requirementText.setText(bidRegulationsContents);				
					}else {
						requirementText.setText(requirementText.getText() + "\r\n" + bidRegulationsContents);				
					}
				}
			});
			dialog.open();
//			MessageDialog.openShortMessage("未找到废标条款！");
		}
	}
	
	
	/**
	 * @Description: 确认评审结果
	 * @author guoyr
	 */
	private void saveEvaluationAction(boolean isSubmit){
		if(applyFlag){
			//if(expertEvaluationResult.getAccessment().equals("02")) {
			if(supplierEvalOpinionText.getText().trim().length() == 0){
				MessageDialog.openShortMessage("请输入"+(isUnqualified ? "否决" : "评审")+"意见！");
				return;
			}
			if(requirementText.getText().trim().length() == 0){
				MessageDialog.openShortMessage("请输入招标文件要求！");
				return;
			}
			//}
			String vetoType = null;
			switch (combo.getSelectionIndex()) {
			case 1:
				vetoType = EvaluationStepEnum.ENTERPRISE_QUALIFICATIONS;
				break;
			case 2:
				vetoType = EvaluationStepEnum.PERFORMANCE_REQUIREMENTS;
				break;
			case 3:
				vetoType = EvaluationStepEnum.PERSONNEL_QUALIFICATIONS;
				break;
			case 4:
				vetoType = EvaluationStepEnum.SERVER_DURATION_SUPPLY;
				break;
			case 5:
				vetoType = EvaluationStepEnum.SUBSTANTIVE_RESPONSE;
				break;
			case 6:
				vetoType = EvaluationStepEnum.REPUTATION_REQUIREMENTS;
				break;
			case 7:
				vetoType = EvaluationStepEnum.BID_VALIDITY_PERIOD;
				break;
			case 8:
				vetoType = EvaluationStepEnum.BID_BOND;
				break;
			case 9:
				vetoType = EvaluationStepEnum.FINANCIAL_REQUIREMENTS;
				break;
			case 10:
				vetoType = EvaluationStepEnum.OTHER_REASONS;
				break;
			default:
				vetoType = "";
				//if(expertEvaluationResult.getAccessment().equals("02")) {
				MessageDialog.openShortMessage("请选择否决类别！");
				return;
				//}
				//break;
			}
			expertEvaluationResult.setSupplierOpinion(supplierEvalOpinionText.getText());
			if(supplierEvaluationResultService.saveSupplierEvaluationOpinion(isSubmit, tenderProject.getId(), supplier.getId(), requirementText.getText(), supplierEvalOpinionText.getText(),vetoType)){
				if(isSubmit){
					supplierEvaluationResult.setApplyUserId(null);
					getShell().close();
				}else {
					MessageDialog.openShortMessage(Messages.Tips_saveSuccess);
				}
				callBack.callBackBoolean(true);
			}else {
				MessageDialog.openError(getShell(), isSubmit ? Messages.Tips_submitFail : Messages.Tips_saveFail);
			}
		}
	}
	
	
	@Override
	public boolean close() {
		if(null != supplierEvaluationResult && null != supplierEvaluationResult.getApplyUserId() && supplierEvaluationResult.getApplyUserId().equals(curUser.getId())){
			supplierEvaluationResultService.releaseEditSupplierEvaluationResult(tenderProject.getId(), supplier.getId(), curUser.getId());
		}
		if(null != callBack) {
			//判断有没有填不合格的理由
			if(requirementText.getText().trim().equals("")||supplierEvalOpinionText.getText().trim().equals("")||combo.getSelectionIndex()==0) {
				callBack.callBackBoolean(false);
				return super.close();
			}
		}
		
		return super.close();
	}

	@Override
	protected Point getInitialSize() {
		return new Point(700, 500);
	}
}
