var ssrfOrgRootId='SSRFProject';

function bindQueryEvent(){
	$('#budgetCode').searchbox({
		type : "hx",name : "budgetCodeChoose",
		onChange:function(value,data){
			$('#budgetCode').val(data.code);
		}
	});
	/*$('#responsiblePersonName').orgTree({
        searchType: 'tech', searchName: 'techOrgSearch',
        filter: "psm", excludePos: 1, param: {orgKindId: "ogn,dpt,pos,psm"},
        onChange: function (value,data) {
        	$('#responsiblePersonId').val(data.personId);
        	$('#responsiblePersonName').val(data.name);
        }
    });*/
	//所属系统选择
	$('#chooseSystemName').orgTree({
        searchType: 'tech', searchName: 'techOrgSearch',
        filter: "dpt", excludePos: 1, param: {orgKindId: "ogn,dpt",orgRoot:ssrfOrgRootId,showVirtualOrg:'1'},
        onChange: function (value,data) {
        	$('#systemId').val(data.id);
        	$('#systemFullId').val(data.fullId);
        	$('#chooseSystemName').val(data.name);
        }
    });
}


function bindChooseSystemName(){
	//所属系统选择
	$('#chooseSystemName').orgTree({
        searchType: 'tech', searchName: 'techOrgSearch',
        filter: "dpt", excludePos: 1, param: {orgKindId: "ogn,dpt",orgRoot:ssrfOrgRootId,showVirtualOrg:'1'},
        onChange: function (value,data) {
        	$('#systemId').val(data.id);
        	$('#systemFullId').val(data.fullId);
        	$('#chooseSystemName').val(data.name);
        	if(!data.id) {
        		$('#collectivityId').val('');
        		$('#collectivityName').val('');
        		$('#subCollectivityId').val('');
        		$('#subCollectivityName').val('');
        		return;
        	}
        	Public.ajax(web_app.name + "/hxPurchaseApproval/queryBudgetOrgInfo.ajax", {fullId: data.fullId}, function (v) {
        		$('#collectivityId').val(v.collectivityId);
        		$('#collectivityName').val(v.collectivityName);
        		$('#subCollectivityId').val(v.subCollectivityId);
        		$('#subCollectivityName').val(v.subCollectivityName);
        	});
        }
    });
}