/*
 * 版 本 PIT-ADMS V7.0.3 敏捷开发框架
 * Copyright (c) 2013-2018 Hexagon PPM
 * 创建人：研发部
 * 日 期：2017.04.18
 * 描 述：岗位选择
 */
var dfopid = request('dfopid');
var selectValue = request('selectValue');
var ProjectId = request('ProjectId');
var acceptClick;
var bootstrap = function ($, learun) {
    "use strict";
    var postitem = { value: '', text: '' };

    var page = {
        init: function (ProjectId) {
            page.bind(ProjectId);
            page.initData();
        },
        bind: function (ProjectId) {
            $('#form_post_list').lrtree({
                url: top.$.rootUrl + '/LR_OrganizationModule/Post/GetOrganizationTree?ProjectId=' + ProjectId,
                nodeClick: function (item) {
                    postitem.value = item.id;
                    postitem.text = item.text;
                }
            });
            $('.form-post-search>input').on("keypress", function (e) {
                if (event.keyCode == "13") {
                    var keyword = $(this).val();
                    $('#form_post_list').lrtreeSet('search', { keyword: keyword });

                }
            });
        },
        initData: function () {
            if (!!selectValue && selectValue != "0") {
                learun.httpAsync('GET', top.$.rootUrl + '/LR_OrganizationModule/Post/GetEntity', { keyValue: selectValue }, function (data) {
                    if (!!data) {
                        //$('#form_company_list').lrtreeSet('setValue', data.F_CompanyId);
                        $('#form_post_list').lrtreeSet('setValue', data.F_PostId);
                    }
                });
            }
        }
    };
    // 保存数据
    acceptClick = function (callBack) {
        callBack(postitem, dfopid);
        return true;
    };
    page.init(ProjectId);
}