<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="workflowmanage.aspx.cs" Inherits="HySoft.BaseCallCenter.Web.workordermanage.workorderset.workflowmanage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>工作流管理</title>
 <link href="../../scripts/ui/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <script src="../../scripts/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="../../scripts/ui/json2.js" type="text/javascript"></script>
    <script src="../../scripts/ui/js/core/base.js" type="text/javascript"></script>
    <script src="../../scripts/ui/js/ligerui.min.js" type="text/javascript"></script>
    <link href="../../scripts/ui/skins/Tab/css/tab.css" rel="stylesheet" type="text/css" />
    <link href="../../scripts/ui/skins/Tab/css/grid.css" rel="stylesheet" type="text/css" />
    <script src="../../scripts/ui/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="../../scripts/ui/js/plugins/ligerLayout.js" type="text/javascript"></script>
    <script src="../../scripts/ui/js/plugins/ligerTree.js" type="text/javascript"></script>
    <script src="../../scripts/ui/js/plugins/ligerMenu.js" type="text/javascript"></script>
    <script src="../../scripts/CustomersData.js" type="text/javascript"></script>
    <link href="../../scripts/ui/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <link href="../../images/style.css" rel="stylesheet" type="text/css" />
    <script src="../../scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript">
        var gridlist;
        $(function () {
            InitList();
        });
        function InitList() {
            var sql = GetSql();
            try {
                gridlist = $("#divDataList").ligerGrid({
                    checkbox: true,
                    height: '100%',
                    columns: [
                { display: 'Id', name: '_f_id', hide: 'Id' },
                { display: '流程编号', name: '_f_id', align: 'left', width: 70 },
                { display: '流程名称', name: '_f_name', width: 70 },
                 { display: '流程状态', name: '_f_state', minWidth: 60, render: function (rowdata, rowindex) {
                     if (rowdata.F_StateFlag == false) { return '未启用'; }
                     else { return '启用'; }
                 }
                 },
                { display: '启用时间', name: '_f_startdate', width: 100, type: 'date', format: 'yyyy-MM-dd hh:mm:ss' },
                { display: '创建时间', name: '_f_createdate', width: 100, type: 'date', format: 'yyyy-MM-dd hh:mm:ss' },
                { display: '创建人', name: '_f_createname', width: 80 },
                { display: '修改时间', name: '_f_editdate', width: 100, type: 'date', format: 'yyyy-MM-dd hh:mm:ss' },
                { display: '修改人', name: '_f_editname', width: 80 }
                ],

                    url: '../ajax/workflowmanageajax.ashx?action=getlist&whereSql=' + sql, pageSize: 10, rownumbers: true
                });
            }
            catch (e) {
                alert(e.Message);
            }
            gridlist.changePage('first');
            $("#pageloading").hide();
        }
        function GetSql() {
            var sql = "";
            if (document.getElementById("txtF_OptName").value != "") {
                sql += " and F_ID='" + document.getElementById("txtF_OptName").value + "'";
            }
            return sql;
        }
        function Delete() {
            try {
                //获取选择的行
                var rows = gridlist.getSelectedRows();
                if (rows.length > 0) {
                    $.ligerDialog.confirm('确定要批量删除选择的记录吗？', function (yes) {
                        if (yes) {
                            try {
                                var arr = new Array();
                                var i = 0;
                                for (var i = 0; i < rows.length; i++) {
                                    arr[i] = rows[i]._f_id;
                                }
                                $.post("../ajax/workflowmanageajax.ashx?action=delete&arrid=" + arr.toString(), function (data) {
                                    if (data == "success") {
                                        $.ligerDialog.success('删除成功');
                                        InitList();
                                    }
                                    else {
                                        $.ligerDialog.error('删除失败');
                                    }
                                });
                            }
                            catch (e) {
                                alert(e.Message);
                            }
                        }
                        else {
                        }
                    });
                }
                else {
                    $.ligerDialog.error('没有选择要删除的日志');
                }
            }
            catch (e) {
                $.ligerDialog.error(e.Message);
            }
        }
        function AddCustomer() {
            var vheight = $("#form1").height() - 100;
            var vwidth = $("#form1").width() * 0.9;
            if (vwidth > 800) {
                vwidth = 800;
            }
            $.ligerDialog.open({ url: 'workflowEdit.aspx?action=add&id=0', title: '编辑流程信息', height: vheight, width: vwidth, isResize: true
            });
        }

        function Edit(param) {
            var selectedRow = gridlist.getSelectedRows();
            if (selectedRow != null && selectedRow.length != 0) {
                if (selectedRow.length > 0 && selectedRow.length < 2) {
                    $.ligerDialog.open({ url: 'workflowEdit.aspx?action=Addedit&id=' + selectedRow[0]._f_id, title: '编辑流程信息', height: 391, width: 800, isResize: true });

                } else {
                    $.ligerDialog.alert("最多修改一条记录!");
                }
            } else {
                $.ligerDialog.alert("请选择修改项!");
            }

        }
        document.onkeydown = function (event) {
            var e = event || window.event || arguments.callee.caller.arguments[0];
            if (e && e.keyCode == 13) {
                InitList();
            }
        };
    </script>
</head>
<body style="overflow:hidden;">
    <form id="form1" runat="server">
    <div class="tools_box">
        <div class="tools_bar">
        <a class="tools_btn" href="#" onclick="AddCustomer();">
                <span><b class="add">添加</b></span>
            </a>
            <a class="tools_btn" href="#" onclick="Edit('edit');">
                <span><b class="modify">修改</b></span>
            </a>
            <a class="tools_btn" href="#" onclick="Delete();"><span>
                    <b class="delete">删除</b></span> </a>

            <div class="search_box">
                关键字：<asp:TextBox ID="txtF_OptName" runat="server" CssClass="txtInput"></asp:TextBox>&nbsp;&nbsp;
                <input id="btnSearch" type="button" value="搜 索" class="btnSearch" onclick="InitList();" />
            </div>
        </div>
    </div>
    <div id="divDataList">
            </div>
    </form>
</body>
</html>
