/*
 * 版 本 PIT-ADMS V7.0.3 敏捷开发框架
 * Copyright (c) 2013-2018 Hexagon PPM
 * 创建人：研发部
 * 日 期：2017.04.18
 * 描 述：选择下一节点审核人员
 */
var acceptClick;
var bootstrap = function ($, learun) {
    "use strict";

    var nodeList = learun.frameTab.currentIframe().nwflow.schemeObj.nodes;
    var nextUsers = learun.frameTab.currentIframe().nwflow.nextUsers;
    var nodeMap = {};

    var page = {
        init: function () {
            $.each(nodeList, function (_index, _item) {
                nodeMap[_item.id] = _item;
            });
            var $form = $('#form');
            $.each(nextUsers, function (_id, _list) {
                if (_list.length > 1) {
                    $form.append('<div class="col-xs-12 lr-form-item"><div class="lr-form-item-title" >' + nodeMap[_id].name.replace('<br/>【多人审核:并行】', '').replace('<br/>【多人审核:串行】', '') + '</div><div id="' + _id + '" class="nodeId" ></div></div >');
                    $('#' + _id).lrselect({
                        type: 'multiple',
                        data: _list,
                        value: 'Id',
                        text: 'Name'
                    });
                }
            });
        }
    };
    // 保存数据
    acceptClick = function (callBack) {
        var formData = $('#form').lrGetFormData();
        // 获取审核人员
        var auditers = {};
        $('#form').find('.nodeId').each(function () {
            var $this = $(this);
            var id = $this.attr('id');
            if (formData[id]) {
                auditers[id] = formData[id];
            }
        });

        callBack(auditers);
        return true;
    };
    page.init();
}