StartProcessDialog.js 2.3 KB
/// <reference path="../jquery-1.11.1.js" />
/// <reference path="../jquery-easyui-1.4.1/jquery.easyui.min.js" />
/// <reference path="../jquery-easyui-ext.js" />
/// <reference path="../global.js" />
/// <reference path="../global.modelctls.js" />
/// <reference path="../global.enums.js" />
/// <reference path="../global.extension.js" />

function StartProcessDialog(options) {
    this._options = options || {};
    this._dialog = null;
    this._callback = this._options.callback;

    this.showDialog = function () {
        var thidpd = this;
        $.post(global.contextPath + global.modelctls.project.list.start, function (data) {
            data = data[0] || [];
            for (var i = 0; i < data.length; i++) {
                data[i].text = data[i].name;
                data[i].type = 'flow';
            }
            thidpd._showDialog([{ id: '流程列表', text: '流程列表', type: 'dir', children: data }]);
        });
    };

    this._showDialog = function (data) {
        var thispd = this;
        var tree = thispd._tree = $('<ul/>');
        var dialog = this._dialog = $('<div style="padding-left:0px;padding-top:0px;"/>').append(tree).dialog({
            title: '选择流程', width: 300, height: 400, modal: true, onOpen: function () {
                $(tree).tree({
                    data: data, checkbox: false, onBeforeCheck: function (node, checked) {

                    }, onClick: function (node) {

                    }
                });
            }, buttons: [{
                text: '确定', iconCls: 'icon-ok', handler: function () {
                    var selected = $(tree).tree('getSelected');
                    if (!selected || selected.type != 'flow') {
                        $.messager.alert('提示', '请选择流程!');
                        return;
                    }
                    if (thispd._callback) thispd._callback(selected);
                    $(dialog).dialog('close');
                }
            }, {
                text: '取消', iconCls: 'icon-cancel', handler: function () {
                    $(dialog).dialog('close');
                }
            }],
            onClose: function () {
                thispd._tree = null;
                thispd._dialog = null;
                $(this).dialog('destroy');
            }
        });
    };
}