使用easyui搭建網頁架子

使用踩坑:javascript

1、彈出框上datagrid第二次加載數據,必須在顯示狀態,datagrid加載數據纔會渲染,不然是空白php

$('#xq_selKs').window('open').window('center'); //必須先顯示窗口再加載數據
$('#xq_gridDXKS').datagrid({
   data:xqAllKsData
});

2、textbox綁定事件,放在函數中觸發會報錯 property textbox undefined 放在$(function(){ })中就正常css

    $(function(){
        //綁定方法
        $("#zxks").textbox('textbox').bind('click',function(){
            xqSelKs();
        });
    });

 3、使用函數給textbox設置值後,再次點擊無效html

<input id="zgks" name="zgksmc" class="easyui-textbox"   label="主管科室:" style="width:100%" labelPosition="top" readonly="readonly"/>

$(function(){
        $("#zgks").textbox('textbox').bind('click',function(){
            xqSelKs();
        });
});

// $('#zxks').textbox({'value':rowData.bmmc});// 第二次點擊無效,觸發不了綁定的點擊事件,塌陷,點不到了?
$("#f_kyxmxq").form("load",{zgksmc:rowData.bmmc});//改用from加載數據便可

 

 

 

主體頁面java

<!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>GCP管理系統</title>
    <link rel="stylesheet" type="text/css" href="js/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="js/themes/icon.css">

    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="js/locale/easyui-lang-zh_CN.js"></script>

    <style type="text/css">
        html, body {
            height: 100%;
            padding: 10px;
            margin: 0px;
            border: 0px;
        }

        .pannelContent {
            padding: 0px;
            background-color: #fff;
        }

        #btn_Exit:link {
            color: white;
            text-decoration: none;
        }

        #btn_Exit:hover {
            color: #afafaf;
            text-decoration: none;
        }
    </style>

    <script>
        $(document).ready(
            function () {
                $('#tt').tree({
                    onClick: function (node) {
                        //alert(node.url);
                        if (node.url) {
                            addPanel(node.text, node.url);
                        }

                    }
                });
            }
        );
        var index = 0;

        function addPanel(tabTitle, tabUrl) {
            /*
            var tab = $('#tab_main').tabs('getTab', tabTitle);
            if (tab)
            {
                alert("有:" + tabTitle);
            }
            */

            if ($('#tab_main').tabs('exists', tabTitle)) {
                $('#tab_main').tabs('select', tabTitle);
            } else {
                index++;
                $('#tab_main').tabs('add', {
                    title: tabTitle,
                    content: '<div style="position: absolute; left:6px; right:6px; top:35px; bottom:0px;"><iframe src="' + tabUrl + '" width=100% height=100% frameborder=0></iframe></div>',
                    closable: true
                });
            }
        }
    </script>
</head>

<body class="easyui-layout">


<div region="north" style=" height:60px; width:100%; overflow:hidden; background-image:url(img/logo_bg.png)" title=""
     collapsible="true" data-options="border:false">
    <img src="img/logo.jpg"/>

</div>

<div data-options="region:'west',split:true" title="功能菜單" style="width:180px;">

    <ul id="tt" class="easyui-tree" data-options="
                //url: 'tree_data1.json',
                //method: 'get',
                lines:true,
                data: [{
                    text: 'Item1',
                    state: 'closed',
                    children: [{
                        text: 'Item11',
                        url: 'login.html'
                    },{
                        text: 'Item12'
                    }]
                },{
                    text: '科研單位信息管理',
                    url:'dwxx.html'
                }],
                animate: true

            "></ul>
</div>

<div id="content" region="center" style="padding:0px; border:0px;">
    <div id="tab_main" class="easyui-tabs" style="width:100%;height:100%">

        <div title="首頁" class="pannelContent">
            <p style="font-size:14px">
                GCP (藥物臨牀試驗質量管理規範) 編輯
                中文名稱爲"藥物臨牀試驗質量管理規範", 是規範藥物臨牀試驗全過程的標準規定,其目的在於保證臨牀試驗過程的規範,結果科學可靠,保護受試者的權益並保障其安全。在我國引入、推進和實施
                GCP已有近十年的時間。我國自1986年起就開始瞭解國際上GCP發展的信息;1992年派員參加了WHO的GCP指南的定稿會議;1993年收集了各國的GCP指導原則並邀請國外專家來華介紹國外實施GCP的狀況;1994年舉辦GCP研討會並開始醞釀起草我國的GCP規範;1995年成立了由5位臨牀藥理專家組成的起草小組,起草了我國《藥品臨牀試驗管理規範》(送審稿),並開始在全國範圍內組織GCP知識的培訓;1998年3月2日衛生部頒佈了《藥品臨牀試驗管理規範)(試行);國家藥品監督管理局成立後對該規範進行了進一步的討論和修改,於1999年9月1日以13號局長令正式頒佈並實施。
                <br>
            </p>

        </div>
    </div>
</div>

<div data-options="region:'south',split:false" style="height:35px; vertical-align:text-bottom">
    <div style=" margin-top:8px; margin-right:8px; height:20px; text-align:right; vertical-align:bottom">
        長沙市中心醫院信息科 copyright 2018
    </div>
</div>

</body>
</html>

經過iframe標籤插入頁面node

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>科研單位信息管理</title>
    <link rel="stylesheet" type="text/css" href="js/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="js/themes/icon.css">
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <script src="js/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="js/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <style>
        html,body{
            height: 100%;
            margin:0;
            padding:0;
        }
    </style>
</head>
<body>
<!-- div劃分區域,各個部分結構-->
<div id="container" style="height:100%">
        <div style="width:100%;margin-left:20px;padding-top: 35px">
            <div style="font-family: 'Times New Roman',Georgia,Serif;font-size:100%;">
                <label style="margin:0">單位名稱:</label> <input id="dwmc" class="easyui-textbox" type="text" style="height:30px;">
                <label style="margin-left:10px;">單位編碼:</label> <input id="dwbm" class="easyui-textbox" type="text" style="height:30px;">
                <label style="margin-left:10px;">可用標誌:</label> <input id="kybz" class="easyui-textbox" type="text" style="height:30px;">
                <div style="display: inline-block;margin-left:10px;">
                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" style="width:70px;height:30px;border:1px solid #95B8E7;" onclick="find()">查找</a>
                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add"  style="width:70px;height:30px;border:1px solid #95B8E7;" onclick="newUser()">添加</a>
                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit"  style="width:70px;height:30px;border:1px solid #95B8E7;" onclick="editUser()">修改</a>
                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove"  style="width:70px;height:30px;border:1px solid #95B8E7;" onclick="deleteUser()">刪除</a>
                </div>
            </div>
        </div>
        <div style="margin-top:15px;margin-bottom:30px;">
            <hr style=" height:2px;border:none;border-top:1px solid #95B8E7;" />
        </div>
        <!--表格-->
        <div style="margin-left:20px">
            <!-- 經過指定表格 url:'1.json' 加載本地數據 -->
            <table id="t_dwxx" title="科研單位信息" class="easyui-datagrid" style="width:900px;height:auto;max-height:900px;min-height: 300px"
                   data-options="url:'js/1.json',pagination:false,rownumbers:true,fitColumns:true,singleSelect:true">
                <!-- 若是開啓分頁,點擊下一頁或改變每頁記錄條數,from提交 頁數page  每頁行數rows-->
                <thead>
                <tr>
                    <th field="dwmc" width="300">單位名稱</th>
                    <th field="dwbm" width="100">單位編碼</th>
                    <th field="kybz" width="100">可用標誌</th>
                </tr>
                </thead>
            </table>

            <!--  默認關閉、隱藏 closed="true" -->
            <div id="dlg" class="easyui-dialog" style="width:400px"
                 closed="true" buttons="#dlg-buttons">
                <!-- enctype 屬性規定在發送到服務器以前應該如何對錶單數據進行編碼;multipart/form-data 不對字符編碼,須要在表單中進行文件上傳時使用。 -->
                <form id="fm" method="post" novalidate style="margin:0;padding:20px 50px">
                    <!--             <div style="margin-bottom:20px;font-size:14px;border-bottom:1px solid #ccc">單位信息</div> -->
                    <div style="margin-bottom:10px">
                        <input name="dwmc" class="easyui-textbox" required="true" label="單位名稱:" style="width:100%">
                    </div>
                    <div style="margin-bottom:10px">
                        <input name="dwbm" class="easyui-textbox" required="true" label="單位編碼:" style="width:100%">
                    </div>
                    <div style="margin-bottom:10px">
                        <input name="kybz" class="easyui-textbox" required="true" label="可用標誌:" style="width:100%">
                    </div>
                </form>
            </div>

            <div id="dlg-buttons">
                <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()"
                   style="width:90px">保存</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel"
                   onclick="javascript:$('#dlg').dialog('close')" style="width:90px">取消</a>
            </div>
        </div>
</div>


<script type="text/javascript">
    var url;
    var type;//new or edit 操做類型
    var param = {};
    $(function () {
        find();
    });
    function find() {
        // var options = $("#t_dwxx" ).datagrid("getPager" ).data("pagination" ).options;
        // var page = options.pageNumber; //查找的時候,page都設置爲1 ? ;帶條件過濾,翻頁?
        // var rows = options.pageSize;

        var dwmc = ($("#dwmc").val()).trim();
        var dwbm = ($("#dwbm").val()).trim();
        var kybz = ($("#kybz").val()).trim();

        var data = {
            dwmc:dwmc,
            dwbm:dwbm,
            kybz:kybz
        };
        $.ajax({
            type: "POST",
            //contentType 發送數據到服務器時所使用的內容類型;用來告訴服務端消息主體是序列化後的 JSON 字符串
            // 表單提交數據是名值對的方式,且Content-Type默認的爲application/x-www-form-urlencoded(在發送前編碼全部字符)
            //jquery默認contentType:'application/x-www-form-urlencoded; charset=UTF-8'
            //若是直接傳json對象則跟上面的相反,不能指定contentType爲 application/json,其默認類型是 application/x-www-form-urlencoded
            // contentType: "application/json", //post發送的數據爲json字符串:JSON.stringify(data)
            //The type of data we expect back;dataType預期的服務器響應的數據類型
            // 設置爲json: Evaluates the response as JSON and returns a JavaScript object.
            contentType:"application/x-www-form-urlencoded; charset=UTF-8",
            dataType: "json",
            url: "search/data",
            data:data, //規定要發送到服務器的數據
            success: function (data) {
                // var data = eval('(' + result + ')');
                if (data && data.rows && data.total) {
                    $('#t_dwxx').datagrid('loadData', data);//Load local data, the old rows will be removed.
                } else {
                    $.messager.alert('Error', "返回數據格式有誤!","error");
                }
            },
            error: function (xhr, status, error) {
                //XMLHttpRequest 對象、錯誤信息、(可選)捕獲的異常對象
                $.messager.alert('Error',"查詢數據失敗!","error");
            }
        })

    }

    function newUser() {
        $('#dlg').dialog('open').dialog('center').dialog('setTitle', '添加');
        $('#fm').form('clear');
        type = "new";
        //點保存saveUser()的以後纔會從fm的form提交到數據庫
    }

    function editUser() {
        var row = $('#t_dwxx').datagrid('getSelected');//Return the first selected row record or null.
        if (row) {
            type = "edit";
            param.olddwbm = row.dwbm;//修改的時候,保存原來的部門編碼
            $('#dlg').dialog('open').dialog('center').dialog('setTitle', '修改');
            $('#fm').form('load', row);//對話框中的form加載選擇row的內容
            url = 'update_user.php?id=' + row.id;
        }
    }

    function saveUser() {
        //保存: $_REQUEST['dwmc'] 能取到dwmc中填的數據
        //作提交
        // data:$('#fm').serialize(),// 序列化表單值
        // console.log($("input[name='dwbm']").val());
        if(type === "new"){
            $('#fm').form('submit', {
                url: url,//經過url區分修改和新增;修改須要知道 舊數據 和 新數據 ;不能只從form提交新數據
                onSubmit: function (param) {
                    // param.value1 = "123";//傳遞額外參數?
                    return $(this).form('validate');
                },
                success: function (result) {
                    var result = eval('(' + result + ')');
                    // 返回  {"result":{
                    // "errorMsg":"……"
                    // }}

                    $('#dlg').dialog('close');        // 關閉對話框
                    $('#t_dwxx').datagrid('reload');    // 從新加載外部表格

                }
            });
        }else if(type === "edit"){
            param.dwbm = $("input[name='dwbm']").val();
            param.dwmc = $("input[name='dwmc']").val();
            param.kybz = $("input[name='kybz']").val();
            $.ajax({
                type: "POST",
                //contentType 發送數據到服務器時所使用的內容類型。
                contentType: "application/json",
                // contentType:"application/x-www-form-urlencoded; charset=UTF-8",
                //dataType預期的服務器響應的數據類型
                dataType: "json",
                url: "edit/data",
                data:param, //規定要發送到服務器的數據
                success: function (result) {
                    var data = eval('(' + result + ')');
                    if (data) {
                        $('#dlg').dialog('close');        // 關閉對話框
                        $('#t_dwxx').datagrid('reload');    // 從新加載外部表格
                    } else {
                        //成功返回數據,可是返回false ?
                        $.messager.alert({
                            title: 'Error',
                            msg: "修改失敗!"
                        });
                    }
                },
                error: function (xhr, status, error) {
                    //XMLHttpRequest 對象、錯誤信息、(可選)捕獲的異常對象
                    $.messager.alert({
                        title: 'Error',
                        msg: "請求失敗:" + status
                    });
                }
            })
        }

    }

    function deleteUser() {
        var row = $('#t_dwxx').datagrid('getSelected');
        if (row) {
            var dwbm = row.dwbm;
            $.messager.confirm('提示', '是否刪除該單位?', function (r) {
                if (r) {
                    //傳遞選中行數據
                    $.post('delete/data', {dwbm: dwbm}, function (result) {
                        // 返回json結構: { result:success }
                        // eval('(' + result + ')') 計算某個字符串,並執行其中的的 JavaScript 代碼
                        // var result = eval('(' + result + ')');//把json 轉爲js對象
                        if (result.success) {
                            $.messager.alert({
                                title: 'Success',
                                msg: "刪除成功!"
                            });
                            $('#t_dwxx').datagrid('reload');    // reload the user data
                        } else {
                            $.messager.alert({    // show error message
                                title: 'Error',
                                msg: "刪除失敗:" + result.errorMsg
                            });
                        }
                    }, 'json');
                }
            });
        }
    }

</script>
</body>
</html>

 項目:jquery

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>科研項目</title>
    <link rel="stylesheet" type="text/css" href="js/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="js/themes/icon.css">
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <script src="js/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="js/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <style>
        html, body {
            height: 100%;
            margin: 0;
            padding: 0;
        }
    </style>
</head>
<body>
<div  id="main" class="easyui-layout" style="height: 100%;padding:0">
    <div data-options="region:'east',title:'科研項目詳情',collapsible:false" style="width:510px;">
        <!--詳情-->
        <div id="xq_toolbar" class="datagrid-toolbar">
            <!--data-options="size:'large'"-->
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-save"
               onclick="saveXmxq()">保存</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-clear"
               onclick="clearXq()">清空</a>
        </div>
        <form id="f_kyxmxq" method="post" novalidate style="margin-left:10px;padding:0" toolbar="#xq_toolbar">
            <table style="width:100%">
                <tr style="display:inline-block;">
                    <!--readonly="readonly"-->
                    <td style="width:150px;"><input id="xq_xmbm" name="xq_xmbm" class="easyui-textbox"  label="項目編碼:" style="width:100%" labelPosition="top" readonly="readonly"></td>
                    <td  style="width:150px;padding-left:5px"><input id="cfdah" name="cfdah" class="easyui-textbox"  label="CFDA批件號:" style="width:100%" labelPosition="top"></td>
                    <td  style="width:150px;padding-left:5px"><input id="ywmc" name="ywmc" class="easyui-textbox" label="藥物名稱:" style="width:100%" labelPosition="top"></td>
                </tr>

                <tr style="display:inline-block;">
                    <td  style="width:150px;">
                        <!--<input name="ywjx" class="easyui-textbox" required="true" label="藥物劑型:" style="width:100%" labelPosition="top">-->
                        <label style="height: 22px;line-height: 22px;vertical-align: middle;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">藥物劑型:</label>
                        <sapn style="height:24px;width:156px;position: relative; background-color: #fff;vertical-align: middle;display: inline-block;overflow: hidden;white-space: nowrap;margin: 0;padding: 0;border-radius: 5px 5px 5px 5px;">
                            <select id="ywjx" name="ywjx" style="width:100%;height:24px;line-height:24px;border:1px solid #95B8E7;border-radius: 5px;outline:none;">
                            </select>
                        </sapn>
                    </td>
                    <td  style="width:150px;padding-left:5px"><input id="syz" name="syz" class="easyui-textbox" label="適應症:" style="width:100%" labelPosition="top"></td>
                    <!--<td  style="width:150px;padding-left:5px"><input name="zcfl" class="easyui-textbox" required="true" label="註冊分類:" style="width:100%" labelPosition="top"></td>-->
                    <td  style="width:150px;padding-left:5px">
                        <label style="height: 22px;line-height: 22px;vertical-align: middle;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">註冊分類:</label>
                        <sapn style="height:24px;width:156px;position: relative; background-color: #fff;vertical-align: middle;display: inline-block;overflow: hidden;white-space: nowrap;margin: 0;padding: 0;border-radius: 5px 5px 5px 5px;">
                            <select id="zcfl" name="zcfl" style="width:100%;height:24px;line-height:24px;border:1px solid #95B8E7;border-radius: 5px;outline:none;">
                            </select>
                        </sapn>
                    </td>
                </tr>

                <tr style="display:inline-block;">
                    <!--<td  style="width:150px;"><input name="syfq" class="easyui-textbox" required="true" label="實驗分期:" style="width:100%" labelPosition="top"></td>-->
                    <td style="width:150px;">
                        <label style="height: 22px;line-height: 22px;vertical-align: middle;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">實驗分期:</label>
                        <sapn style="height:24px;width:156px;position: relative; background-color: #fff;vertical-align: middle;display: inline-block;overflow: hidden;white-space: nowrap;margin: 0;padding: 0;border-radius: 5px 5px 5px 5px;">
                            <select id="syfq" name="syfq" style="width:100%;height:24px;line-height:24px;border:1px solid #95B8E7;border-radius: 5px;outline:none;">
                            </select>
                        </sapn>
                    </td>
                    <!--<td  style="width:150px;padding-left:5px"><input name="lxlb" class="easyui-textbox" required="true" label="立項類別:" style="width:100%" labelPosition="top"></td>-->
                    <td style="width:150px;padding-left:5px">
                        <label style="height: 22px;line-height: 22px;vertical-align: middle;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">立項類別:</label>
                        <sapn style="height:24px;width:156px;position: relative; background-color: #fff;vertical-align: middle;display: inline-block;overflow: hidden;white-space: nowrap;margin: 0;padding: 0;border-radius: 5px 5px 5px 5px;">
                            <select id="lxlb" name="lxlb" style="width:100%;height:24px;line-height:24px;border:1px solid #95B8E7;border-radius: 5px;outline:none;">
                            </select>
                        </sapn>
                    </td>
                    <td  style="width:150px;padding-left:5px">
                        <!--<input id="scxs" name="scxs" class="easyui-textbox" required="true" label="審查形式:" style="width:100%" labelPosition="top">-->
                        <label style="height: 22px;line-height: 22px;vertical-align: middle;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">審查形式:</label>
                        <sapn style="height:24px;width:156px;position: relative; background-color: #fff;vertical-align: middle;display: inline-block;overflow: hidden;white-space: nowrap;margin: 0;padding: 0;border-radius: 5px 5px 5px 5px;">
                            <select id="scxs" name="scxs" style="width:100%;height:24px;line-height:24px;border:1px solid #95B8E7;border-radius: 5px;outline:none;">
                            </select>
                        </sapn>
                    </td>
                </tr>

                <tr style="display:inline-block;">
                    <td  style="width:150px;"><input id="sbz" name="sbz" class="easyui-textbox" label="申辦者:" style="width:100%" labelPosition="top"></td>
                    <td  style="width:150px;padding-left:5px"><input id="sbzlxdh" name="sbzlxdh" class="easyui-textbox"   label="申辦者聯繫方式:" style="width:100%" labelPosition="top"></td>
                    <td  style="width:150px;padding-left:5px"><input id="cro" name="cro" class="easyui-textbox"   label="CRO:" style="width:100%" labelPosition="top"></td>
                </tr>

                <tr style="display:inline-block;">
                    <td  style="width:150px;"><input id="crolxdh" name="crolxdh" class="easyui-textbox"  label="CRO聯繫方式:" style="width:100%" labelPosition="top"></td>
                    <td  style="width:150px;padding-left:5px"><input id="zzdw" name="zzdw" class="easyui-textbox"   label="組長單位:" style="width:100%" labelPosition="top"></td>
                    <td  style="width:150px;padding-left:5px"><input id="zzdwyjy" name="zzdwyjy" class="easyui-textbox"   label="組長單位主要研究者:" style="width:100%" labelPosition="top"></td>
                </tr>

                <tr style="display:inline-block;">
                    <td  style="width:150px;"><input id="bzxcdjy" name="bzxcdjy" class="easyui-textbox"   label="本中心承擔專業:" style="width:100%" labelPosition="top"></td>
                    <td  style="width:150px;padding-left:5px"><input id="bzxcdjyyjy" name="bzxcdjyyjy" class="easyui-textbox"   label="本中心承擔專業研究者:" style="width:99%" labelPosition="top"></td>
                    <td  style="width:150px;padding-left:5px"><input id="jhls" name="jhls" class="easyui-textbox"   label="計劃完成總例數:" style="width:100%" labelPosition="top"></td>
                </tr>

                <tr style="display:inline-block;">
                    <td  style="width:150px;"><input id="yyls" name="yyls" class="easyui-textbox"   label="本中心計劃完成例數:" style="width:100%" labelPosition="top"></td>
                    <td  style="width:150px;padding-left:5px"><input id="zgks" name="zgksmc" class="easyui-textbox"   label="主管科室:" style="width:100%" labelPosition="top" readonly="readonly"></td>
                    <td  style="width:150px;padding-left:5px"><input id="zgys" name="zgysxm" class="easyui-textbox"   label="主管醫生:" style="width:100%" labelPosition="top" readonly="readonly"></td>
                </tr>

            </table>
        </form>

        <!--階段表格-->
        <div style="margin-top:10px;width:100%;">
            <!--rownumbers:true,-->
            <table id="t_jd" title="科研項目階段" class="easyui-datagrid"
                   style="width:100%;height:auto;max-height: 210px"
                   data-options="pagination:false,fitColumns:true,singleSelect:true" toolbar="#jd_toolbar">
            </table>
        </div>



    </div>

    <div data-options="region:'center'" style="width:100%;height: 100%;padding:0">
        <!--工具條-->
        <div style="max-width:570px;margin:0 auto;padding-top:10px;padding-bottom:10px;">
            <div style="font-family: 'Times New Roman',Georgia,Serif,'Microsoft YaHei',sans-serif;font-size:12px;">
                <label style="margin:0">項目名稱:</label> <input id="xmmc" class="easyui-textbox" type="text"
                                                             style="height:30px;width:110px;">
                <!--<label style="margin-left:10px;">項目編碼:</label> <input id="xmbm" class="easyui-textbox" type="text"-->
                <!--style="height:30px;width:150px;">-->
                <label style="margin-left:10px;">項目狀態:</label>
                <sapn style="height:30px;width:60px;position: relative; background-color: #fff;vertical-align: middle;display: inline-block;overflow: hidden;white-space: nowrap;margin: 0;padding: 0;border-radius: 5px 5px 5px 5px;">
                    <select id="zt" name="zt" style="width:100%;height:30px;line-height:30px;border:1px solid #95B8E7;border-radius: 5px;outline:none;font-family: 'Times New Roman',Georgia,Serif,'Microsoft YaHei',sans-serif;">
                        <option value="all">所有</option>
                        <option value="1">申請</option>
                        <option value="2">已審批</option>
                        <option value="3">已做廢</option>
                    </select>
                </sapn>

                <div style="display: inline-block;margin-left:10px;">
                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search"
                       style="width:60px;height:30px;border:1px solid #95B8E7;" onclick="find()">查找</a>
                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add"
                       style="width:60px;height:30px;border:1px solid #95B8E7;" onclick="newXm()">添加</a>
                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit"
                       style="width:60px;height:30px;border:1px solid #95B8E7;" onclick="editXm()">修改</a>
                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove"
                       style="width:60px;height:30px;border:1px solid #95B8E7;" onclick="deleteXm()">刪除</a>
                </div>
            </div>
        </div>

        <!--項目信息 表格-->
        <div style="width:100%;position:absolute;top:50px;bottom:0;left:0;">
            <table id="t_kyxm" title="科研項目信息" class="easyui-datagrid"
                   style="width:100%;height:100%;"
                   data-options="pagination:false,rownumbers:true,fitColumns:true,singleSelect:true">
            </table>
        </div>
    </div>
</div>

<!--添加 項目 對話框-->
<div id="new_dlg" class="easyui-dialog" style="width:400px" closed="true" buttons="#new_dlg-buttons" data-options="draggable:true,modal:true">
    <form id="new_fm" method="post" novalidate style="margin:0;padding:20px 50px">
        <div style="margin-bottom:10px">
            <label style="display:inline-block;width:80px;text-align: left;height: 24px;line-height: 24px">科研單位:</label>
            <sapn style="height:30px;width:201px;position: relative; background-color: #fff;vertical-align: middle;display: inline-block;overflow: hidden;white-space: nowrap;margin: 0;padding: 0;border-radius: 5px 5px 5px 5px;">
                <select id="new_kydwmc" name="new_kydwmc" style="width: 201px; margin: 0; padding:0 4px;height: 24px; line-height: 24px;border:1px solid #95B8E7;border-radius: 5px;outline:none;font-family: Arial;font-size: 12px">
                </select>
            </sapn>
        </div>
        <div style="margin-bottom:10px">
            <input name="new_xmmc" class="easyui-textbox" required="true" label="項目名稱:" style="width:100%">
        </div>
        <div style="margin-bottom:10px">
            <!--<input name="new_xmlx" class="easyui-textbox" required="true" label="項目類型:" style="width:100%">-->
            <label style="display:inline-block;width:80px;text-align: left;height: 24px;line-height: 24px">項目類型:</label>
            <sapn style="height:30px;width:201px;position: relative; background-color: #fff;vertical-align: middle;display: inline-block;overflow: hidden;white-space: nowrap;margin: 0;padding: 0;border-radius: 5px 5px 5px 5px;">
                <select id="new_xmlx" name="new_xmlx" style="width: 201px; margin: 0; padding:0 4px;height: 24px; line-height: 24px;border:1px solid #95B8E7;border-radius: 5px;outline:none;font-family: Arial;font-size: 12px">
                    <option value="1">藥物臨牀試驗</option>
                    <option value="2">醫療器械臨牀試驗</option>
                    <option value="3">診斷試劑臨牀試驗</option>
                    <option value="4">其餘</option>
                </select>
            </sapn>
        </div>
        <div style="margin-bottom:10px">
            <label style="display:inline-block;width:80px;text-align: left;height: 24px;line-height: 24px">報銷類型:</label>
            <sapn style="height:30px;width:201px;position: relative; background-color: #fff;vertical-align: middle;display: inline-block;overflow: hidden;white-space: nowrap;margin: 0;padding: 0;border-radius: 5px 5px 5px 5px;">
                <select id="new_fylx" name="fylx" style="width: 201px; margin: 0; padding:0 4px;height: 24px; line-height: 24px;border:1px solid #95B8E7;border-radius: 5px;outline:none;font-family: Arial;font-size: 12px">
                    <option value="1">所有報銷</option>
                    <option value="2">部分報銷</option>
                    <option value="3">手工報銷</option>
                </select>
            </sapn>
        </div>

        <div style="margin-bottom:10px">
            <!--<input name="yxrq" class="easyui-textbox" required="true" label="立項日期:" style="width:100%">-->
            <input name="new_yxrq" class="easyui-datebox" label="立項日期:"  required="true"  labelPosition="left" style="width:100%;">
        </div>

    </form>
</div>

<div id="new_dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveNew()"
       style="width:90px">保存</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel"
       onclick="closeDlg('new_dlg')" style="width:90px">取消</a>
</div>
<!--編輯 項目 對話框-->
<div id="edit_dlg" class="easyui-dialog" style="width:400px" closed="true" buttons="#edit_dlg-buttons" data-options="draggable:true,modal:true">
    <form id="edit_fm" method="post" novalidate style="margin:0;padding:20px 50px">
        <div style="margin-bottom:10px">
            <input name="xmmc" class="easyui-textbox" required="true" label="項目名稱:" style="width:100%">
        </div>
        <div style="margin-bottom:10px">
            <!--<input name="kydwmc" class="easyui-textbox" required="true" label="科研單位:" style="width:100%">-->
            <label style="display:inline-block;width:80px;text-align: left;height: 24px;line-height: 24px">科研單位:</label>
            <sapn style="height:30px;width:201px;position: relative; background-color: #fff;vertical-align: middle;display: inline-block;overflow: hidden;white-space: nowrap;margin: 0;padding: 0;border-radius: 5px 5px 5px 5px;">
                <select id="edit_kydwmc" name="edit_kydwmc" style="width: 201px; margin: 0; padding:0 4px;height: 24px; line-height: 24px;border:1px solid #95B8E7;border-radius: 5px;outline:none;font-family: Arial;font-size: 12px">
                </select>
            </sapn>
        </div>
        <div style="margin-bottom:10px">
            <!--<input name="xmlx" class="easyui-textbox" required="true" label="項目類型:" style="width:100%">-->
            <label style="display:inline-block;width:80px;text-align: left;height: 24px;line-height: 24px">項目類型:</label>
            <sapn style="height:30px;width:201px;position: relative; background-color: #fff;vertical-align: middle;display: inline-block;overflow: hidden;white-space: nowrap;margin: 0;padding: 0;border-radius: 5px 5px 5px 5px;">
                <select id="edit_xmlx" name="xmlx" style="width: 201px; margin: 0; padding:0 4px;height: 24px; line-height: 24px;border:1px solid #95B8E7;border-radius: 5px;outline:none;font-family: Arial;font-size: 12px">
                    <option value="1">藥物臨牀試驗</option>
                    <option value="2">醫療器械臨牀試驗</option>
                    <option value="3">診斷試劑臨牀試驗</option>
                    <option value="4">其餘</option>
                </select>
            </sapn>
        </div>
        <div style="margin-bottom:10px">
            <label style="display:inline-block;width:80px;text-align: left;height: 24px;line-height: 24px">報銷類型:</label>
            <sapn style="height:30px;width:201px;position: relative; background-color: #fff;vertical-align: middle;display: inline-block;overflow: hidden;white-space: nowrap;margin: 0;padding: 0;border-radius: 5px 5px 5px 5px;">
                <select id="edit_fylx" name="fylx" style="width: 201px; margin: 0; padding:0 4px;height: 24px; line-height: 24px;border:1px solid #95B8E7;border-radius: 5px;outline:none;font-family: Arial;font-size: 12px">
                    <option value="1">所有報銷</option>
                    <option value="2">部分報銷</option>
                    <option value="3">手工報銷</option>
                </select>
            </sapn>
        </div>
        <div style="margin-bottom:10px">
            <label style="display:inline-block;width:80px;text-align: left;height: 24px;line-height: 24px">項目狀態:</label>
            <sapn style="height:30px;width:201px;position: relative; background-color: #fff;vertical-align: middle;display: inline-block;overflow: hidden;white-space: nowrap;margin: 0;padding: 0;border-radius: 5px 5px 5px 5px;">
                <select id="edit_zt" name="zt" style="width: 201px; margin: 0; padding:0 4px;height: 24px; line-height: 24px;border:1px solid #95B8E7;border-radius: 5px;outline:none;font-family: Arial;font-size: 12px">
                    <option value="1">申請</option>
                    <option value="2">已審批</option>
                    <option value="3">已做廢</option>
                </select>
            </sapn>
        </div>
        <div style="margin-bottom:10px">
            <!--<input name="yxrq" class="easyui-textbox" required="true" label="立項日期:" style="width:100%">-->
            <input name="yxrq" class="easyui-datebox" label="立項日期:"  required="true"  labelPosition="left" style="width:100%;">
        </div>

    </form>
</div>

<div id="edit_dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveEdit()"
       style="width:90px">保存</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel"
       onclick="closeDlg('edit_dlg')" style="width:90px">取消</a>
</div>

<!--階段 增 刪 改 按鈕-->
<div id="jd_toolbar">
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" onclick="addStage()">新增</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" onclick="editStage()">修改</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" onclick="deleteStage()">刪除</a>
</div>

<!--新增 階段-->
<div id="newjd_dlg" class="easyui-dialog" style="width:400px" closed="true" buttons="#newjd_dlg-buttons" data-options="draggable:true,modal:true">
    <form id="newjd_fm" method="post" novalidate style="margin:0;padding:20px 50px">
        <div style="margin-bottom:10px">
            <input id="jd_xmbm" name="jd_xmbm" class="easyui-textbox" required="true" label="項目編碼:" style="width:100%" readonly="readonly">
        </div>
        <div style="margin-bottom:10px">
            <input name="jdmc" class="easyui-textbox" required="true" label="階段名稱:" style="width:100%">
        </div>
        <div style="margin-bottom:10px">
            <!--<input name="kydwmc" class="easyui-textbox" required="true" label="科研單位:" style="width:100%">-->
            <label style="display:inline-block;width:80px;text-align: left;height: 24px;line-height: 24px">階段類型:</label>
            <sapn style="height:30px;width:201px;position: relative; background-color: #fff;vertical-align: middle;display: inline-block;overflow: hidden;white-space: nowrap;margin: 0;padding: 0;border-radius: 5px 5px 5px 5px;">
                <select id="new_jdlx" name="new_jdlx" style="width: 201px; margin: 0; padding:0 4px;height: 24px; line-height: 24px;border:1px solid #95B8E7;border-radius: 5px;outline:none;font-family: Arial;font-size: 12px">
                    <option value="1">篩選階段</option>
                    <option value="2">治療階段</option>
                    <option value="3">隨訪階段</option>
                </select>
            </sapn>
        </div>

    </form>
</div>

<div id="newjd_dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveJd()"
       style="width:90px">保存</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel"
       onclick="closeDlg('newjd_dlg')" style="width:90px">取消</a>
</div>

<!--編輯 階段-->
<div id="editjd_dlg" class="easyui-dialog" style="width:400px" closed="true" buttons="#editjd_dlg-buttons" data-options="draggable:true,modal:true">
    <form id="editjd_fm" method="post" novalidate style="margin:0;padding:20px 50px">
        <div style="margin-bottom:10px">
            <input id="editjd_xmbm" name="xmbm" class="easyui-textbox" required="true" label="項目編碼:" style="width:100%" readonly="readonly">
        </div>
        <div style="margin-bottom:10px">
            <input id="edit_xh" name="xh" class="easyui-textbox" required="true" label="序號:" style="width:100%" readonly="readonly">
        </div>
        <div style="margin-bottom:10px">
            <input id="edit_jdmc" name="jdmc" class="easyui-textbox" required="true" label="階段名稱:" style="width:100%">
        </div>
        <div style="margin-bottom:10px">
            <!--<input name="kydwmc" class="easyui-textbox" required="true" label="科研單位:" style="width:100%">-->
            <label style="display:inline-block;width:80px;text-align: left;height: 24px;line-height: 24px">階段類型:</label>
            <sapn style="height:30px;width:201px;position: relative; background-color: #fff;vertical-align: middle;display: inline-block;overflow: hidden;white-space: nowrap;margin: 0;padding: 0;border-radius: 5px 5px 5px 5px;">
                <select id="edit_jdlx" name="new_jdlx" style="width: 201px; margin: 0; padding:0 4px;height: 24px; line-height: 24px;border:1px solid #95B8E7;border-radius: 5px;outline:none;font-family: Arial;font-size: 12px">
                    <option value="1">篩選階段</option>
                    <option value="2">治療階段</option>
                    <option value="3">隨訪階段</option>
                </select>
            </sapn>
        </div>

    </form>
</div>

<div id="editjd_dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveEditJd()"
       style="width:90px">保存</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel"
       onclick="closeDlg('editjd_dlg')" style="width:90px">取消</a>
</div>

<!--人員維護-->
<div id="winSelRy" class="easyui-dialog" title="參與人員"
     data-options="modal:true,buttons:'#winSelRyBtn',closed:true,resizable:true,iconCls:'icon-save'"
     style=" width:500px;height:500px;padding:10px;">

    <table id="gridYXRY" class="easyui-datagrid" title="已選參與人員" style="width:100%;height:180px"
           data-options="singleSelect:true,collapsible:false,
            onDblClickRow:function(rowIndex, rowData){
                //alert(rowData.czydm);
                for(var i = 0; i < selRyData.length; i++)
                {
                    if (selRyData[i].czydm == rowData.czydm)
                    {
                        selRyData.splice(i,1);
                        $('#gridYXRY').datagrid({
                            data:selRyData
                        });
                        break;
                    }
                }
            }
            ">
        <thead>
        <tr>
            <th data-options="field:'bmmc',width:180,align:'left'">部門名稱</th>
            <th data-options="field:'czydm',width:80,align:'center'">工號</th>
            <th data-options="field:'czyxm',width:80,align:'center'">姓名</th>
            <th data-options="field:'lxdh',width:100,align:'center'">聯繫電話</th>
        </tr>
        </thead>
    </table>

    <div style="margin-top:10px;"></div>

    <input id="txtSearchRy" class="easyui-searchbox" style="width:100%;"
           data-options="searcher:SearchRy,prompt:'請輸入工號、姓名或拼音碼查找人員'"></input>

    <div style="margin-top:10px;"></div>

    <table id="gridDXRY" class="easyui-datagrid" title="待選人員" style="width:100%; height:180px; "
           data-options="singleSelect:true,collapsible:false,
            onDblClickRow:function(rowIndex, rowData){
                //alert(rowData.czydm);
                try{
                    var bFind = false;
                    for(var i = 0; i < selRyData.length; i++)
                    {
                        if (selRyData[i].czydm == rowData.czydm)
                        {
                            bFind = true;
                            break;
                        }
                    }
                    if (!bFind)
                    {
                        selRyData.push(rowData);
                        $('#gridYXRY').datagrid({
                            data:selRyData
                        });
                    }
                }
                catch(e){
                    alert('err:' + e.description);
                }
            }
            ">
        <thead>
        <tr>
            <th data-options="field:'bmmc',width:180,align:'left'">部門名稱</th>
            <th data-options="field:'czydm',width:80,align:'center'">工號</th>
            <th data-options="field:'czyxm',width:80,align:'center'">姓名</th>
            <th data-options="field:'lxdh',width:100,align:'center'">聯繫電話</th>
        </tr>
        </thead>
    </table>

</div>

<div id="winSelRyBtn">
    <a id="btnSaveRy" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:false" onclick="SaveRy()">保存</a>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$('#winSelRy').window('close');">取消</a>
</div>


<!--科室維護-->
<div id="winSelKs" class="easyui-dialog" title="參與科室"
     data-options="modal:true,buttons:'#winSelKsBtn',closed:true,resizable:true,iconCls:'icon-save'"
     style=" width:500px;height:500px;padding:10px;">

    <table id="gridYXKS" class="easyui-datagrid" title="已選參與科室" style="width:100%;height:180px"
           data-options="singleSelect:true,collapsible:false,
            onDblClickRow:function(rowIndex, rowData){
                //alert(rowData.bmbm);
                for(var i = 0; i < selKsData.length; i++)
                {
                    if (selKsData[i].bmbm == rowData.bmbm)
                    {
                        selKsData.splice(i,1);
                        $('#gridYXKS').datagrid({
                            data:selKsData
                        });
                        break;
                    }
                }
            }
            ">
        <thead>
        <tr>
            <th data-options="field:'bmmc',width:360,align:'left'">部門名稱</th>
            <th data-options="field:'bmbm',width:80,align:'center'">部門編碼</th>
        </tr>
        </thead>
    </table>

    <div style="margin-top:10px;"></div>


    <input id="txtSearchKS" class="easyui-searchbox" style="width:100%;"
           data-options="searcher:SearchKs,prompt:'請輸入科室名或拼音碼查找科室'"></input>

    <div style="margin-top:10px;"></div>

    <table id="gridDXKS" class="easyui-datagrid" title="待選科室" style="width:100%; height:180px; "
           data-options="singleSelect:true,collapsible:false,
            onDblClickRow:function(rowIndex, rowData){
                try{
                    var bFind = false;
                    for(var i = 0; i < selKsData.length; i++)
                    {
                        if (selKsData[i].bmbm == rowData.bmbm)
                        {
                            bFind = true;
                            break;
                        }
                    }
                    if (!bFind)
                    {
                        selKsData.push(rowData);
                        $('#gridYXKS').datagrid({
                            data:selKsData
                        });
                    }
                }
                catch(e){
                    alert('err:' + e.description);
                }
            }
            ">
        <thead>
        <tr>
            <th data-options="field:'bmmc',width:360,align:'left'">部門名稱</th>
            <th data-options="field:'bmbm',width:80,align:'center'">部門編碼</th>
        </tr>
        </thead>
    </table>

</div>
<div id="winSelKsBtn">
    <a id="btnSaveKs" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:false" onclick="SaveKs()">保存</a>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$('#winSelKs').window('close');">取消</a>
</div>

<!--醫囑維護-->
<div id="winSelYz" class="easyui-dialog" title="階段醫囑"
     data-options="modal:true,buttons:'#winSelYzBtn',closed:true,resizable:true,iconCls:'icon-save'"
     style=" width:700px;height:500px;padding:10px;">

    <table id="gridYXYZ" class="easyui-datagrid" style="width:100%;height:405px"
           data-options="singleSelect:true,collapsible:false,
            onDblClickRow:function(rowIndex, rowData){
                //alert(rowData.bmbm);
                /*
                if (window.confirm('確認要刪除本條醫囑?'))
                {
                    for(var i = 0; i < selYzData.length; i++)
                    {
                        if (selYzData[i].dm == rowData.dm)
                        {
                            selYzData.splice(i,1);
                            $('#gridYXYZ').datagrid({
                                data:selYzData
                            });
                            break;
                        }
                    }
                }
                */
            }
            ">
        <thead>
        <tr>
            <th data-options="field:'yzlb',width:80,align:'center'">醫囑分類</th>
            <th data-options="field:'yzdm',width:80,align:'center'">醫囑代碼</th>
            <th data-options="field:'yzmc',width:200,align:'left'">醫囑名稱</th>
            <th data-options="field:'zxksmc',width:90,align:'center'">執行科室</th>
            <th data-options="field:'bzxmmc',width:40,align:'center'">必作</th>
            <th data-options="field:'kybzmc',width:40,align:'center'">可用</th>
            <th data-options="field:'jzfsmc',width:50,align:'center'">記帳方式</th>
            <th data-options="field:'jl',width:40,align:'center'">劑量</th>
            <th data-options="field:'yfmc',width:40,align:'center'">用法</th>
            <th data-options="field:'yfsm',width:80,align:'center'">用法說明</th>
            <th data-options="field:'pdldw',width:40,align:'center'">頻度</th>
            <th data-options="field:'ts',width:40,align:'center'">天數</th>
            <th data-options="field:'zsl',width:60,align:'center'">總數量</th>
            <th data-options="field:'xh',width:40,align:'center'">序號</th>
        </tr>
        </thead>
    </table>

</div>
<div id="winSelYzBtn">
    <a id="btnNewYz" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:false" onclick="NewYz(0)">新增</a>
    <a id="btnEditYz" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:false" onclick="NewYz(1)">修改</a>
    <a id="btnDelYz" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:false" onclick="NewYz(2)">刪除</a>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$('#winSelYz').window('close');">取消</a>
</div>



<div id="winAddYz" class="easyui-dialog" title="添加醫囑"
     data-options="modal:true,buttons:'#winAddYzBtn',closed:true,resizable:true,iconCls:'icon-save'"
     style=" width:500px;height:500px;padding:10px;">

    <form id="formAddYz">

        <div style="margin-top:10px;"></div>
        <div style="display:inline-block;margin-top:10px">
            序  號:<input id="ctrl_XH" class="easyui-numberspinner" value="1" data-options="increment:1,min:0,max:10000" style="width:80px;" />
            必作項目:<input id="ctrl_BZXM" type="checkbox" value="1" />&nbsp;
            可用標誌:<input id="ctrl_KYBZ" type="checkbox" value="1" />&nbsp;
            記帳方式:<input id="ctrl_JZFS" type="checkbox" value="1"/>&nbsp;
        </div>

        <div style="display:inline-block;margin-top:10px">
            醫  囑:<input id="ctrl_YZMC" type="text" style="width:120px;" readonly />
            <input id="ctrl_YZLB" type="text" style="width:60px;" readonly/>
            <a href="javascript:$('#winAddYz_yz').window('open').window('center');" class="easyui-linkbutton" data-options="iconCls:'icon-add'">選擇醫囑</a>
        </div>

        <div style="display:inline-block;margin-top:10px">
            執行科室:<input id="ctrl_ZXKSMC" type="text"  style="width:120px;" readonly/>
            <input id="ctrl_ZXKS" type="text" style="width:60px;" readonly/>
            <a href="javascript:$('#winAddYz_ks').window('open').window('center');" class="easyui-linkbutton" data-options="iconCls:'icon-add'">選擇科室</a>
        </div>

        <div style="display:inline-block;margin-top:10px">
            劑  量:<input id="ctrl_JL" class="easyui-numberbox" value="0" data-options="min:0,precision:2" style="width:80px;" />

            用 法:<input id="ctrl_YFMC" type="text" style="width:60px;" readonly />
            <a href="javascript:$('#winAddYz_yf').window('open').window('center');" class="easyui-linkbutton" data-options="iconCls:'icon-add'">選擇用法</a>
        </div>

        <div style="display:inline-block;margin-top:10px">
            用法說明:<textarea id="ctrl_YFSM" style="width:300px;height:80px;" maxlength="30"></textarea>
        </div>

        <div style="display:inline-block;margin-top:10px">
            頻  度:<input id="ctrl_PDMC" type="text" style="width:120px;" readonly />
            <input id="ctrl_PDLDW" type="text" style="width:60px;" readonly />
            <a href="javascript:$('#winAddYz_pd').window('open').window('center');" class="easyui-linkbutton" data-options="iconCls:'icon-add'">選擇頻度</a>
        </div>

        <div style="display:inline-block;margin-top:10px">
            天  數:<input id="ctrl_TS" class="easyui-numberspinner" value="1" data-options="increment:1,min:0,max:1000" style="width:80px;" />
            總數量:<input id="ctrl_ZSL" class="easyui-numberbox" value="0" data-options="min:0,precision:2" style="width:80px;" />
        </div>

    </form>
</div>
<div id="winAddYzBtn">
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:false" onclick="SaveYz()">保存</a>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$('#winAddYz').window('close'); $('#formAddYz').form('clear');">取消</a>
</div>



<div id="winAddYz_yz" class="easyui-dialog" title="選擇醫囑"
     data-options="modal:true,buttons:'#winAddYzYzBtn',closed:true,resizable:true,iconCls:'icon-save'"
     style=" width:500px;height:400px;padding:10px;">

    <input id="txtAddSearchYZ" class="easyui-searchbox" style="width:100%;"
           data-options="searcher:SearchAddYz,prompt:'請輸入醫囑名或拼音碼查找醫囑'"></input>

    <div style="margin-top:10px;"></div>

    <table id="gridAddDXYZ" class="easyui-datagrid" title="待選醫囑" style="width:100%; height:270px; "
           data-options="singleSelect:true,collapsible:false,
                onDblClickRow:function(rowIndex, rowData){
                try{
                    //序號、執行科室、必作項目、可用標誌、劑量、用法10九、用法說明、頻度sys_pd_sypd、天數、總數量
                    //id,gyid,xh,yzlb,yzdm,yzmc,zxks,bzxm,kybz,jl,yf,yfsm,pd,ts,zsl
                    winAddYz_YzConfirm();
                }
                catch(e){
                    alert('err:' + e.description);
                }
            }
            ">
        <thead>
        <tr>
            <th data-options="field:'yzfl',width:80,align:'center'">醫囑分類</th>
            <th data-options="field:'dmmc',width:360,align:'left'">醫囑名稱</th>
        </tr>
        </thead>
    </table>
</div>
<div id="winAddYzYzBtn">
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:false" onclick="winAddYz_YzConfirm()">肯定</a>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$('#winAddYz_yz').window('close');">取消</a>
</div>




<div id="winAddYz_ks" class="easyui-dialog" title="選擇科室"
     data-options="modal:true,buttons:'#winAddYzKsBtn',closed:true,resizable:true,iconCls:'icon-save'"
     style=" width:500px;height:400px;padding:10px;">

    <input id="txtAddSearchKS" class="easyui-searchbox" style="width:100%;"
           data-options="searcher:SearchAddKs,prompt:'請輸入科室名或拼音碼查找科室'"></input>

    <div style="margin-top:10px;"></div>

    <table id="gridAddDXKS" class="easyui-datagrid" title="待選科室" style="width:100%; height:270px; "
           data-options="singleSelect:true,collapsible:false,
                onDblClickRow:function(rowIndex, rowData){
                try{
                    winAddYz_KsConfirm();
                }
                catch(e){
                    alert('err:' + e.description);
                }
            }
            ">
        <thead>
        <tr>
            <th data-options="field:'bmmc',width:360,align:'left'">部門名稱</th>
            <th data-options="field:'bmbm',width:80,align:'center'">部門編碼</th>
        </tr>
        </thead>
    </table>
</div>
<div id="winAddYzKsBtn">
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:false" onclick="winAddYz_KsConfirm()">肯定</a>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$('#winAddYz_ks').window('close');">取消</a>
</div>




<div id="winAddYz_yf" class="easyui-dialog" title="選擇用法"
     data-options="modal:true,buttons:'#winAddYzYfBtn',closed:true,resizable:true,iconCls:'icon-save'"
     style=" width:500px;height:400px;padding:10px;">

    <input id="txtAddSearchYF" class="easyui-searchbox" style="width:100%;"
           data-options="searcher:SearchAddYf,prompt:'請輸入用法名或代碼查找用法'"></input>

    <div style="margin-top:10px;"></div>

    <table id="gridAddDXYF" class="easyui-datagrid" title="待選用法" style="width:100%; height:270px; "
           data-options="singleSelect:true,collapsible:false,
                onDblClickRow:function(rowIndex, rowData){
                try{
                    winAddYz_YfConfirm();
                }
                catch(e){
                    alert('err:' + e.description);
                }
            }
            ">
        <thead>
        <tr>
            <th data-options="field:'uname',width:360,align:'left'">用法名稱</th>
            <th data-options="field:'dm',width:80,align:'center'">用法編碼</th>
        </tr>
        </thead>
    </table>
</div>
<div id="winAddYzYfBtn">
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:false" onclick="winAddYz_YfConfirm()">肯定</a>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$('#winAddYz_yf').window('close');">取消</a>
</div>


<div id="winAddYz_pd" class="easyui-dialog" title="選擇頻度"
     data-options="modal:true,buttons:'#winAddYzPdBtn',closed:true,resizable:true,iconCls:'icon-save'"
     style=" width:500px;height:400px;padding:10px;">

    <input id="txtAddSearchPD" class="easyui-searchbox" style="width:100%;"
           data-options="searcher:SearchAddPd,prompt:'請輸入頻度名稱、代碼或拉丁文查找用法'"></input>

    <div style="margin-top:10px;"></div>

    <table id="gridAddDXPD" class="easyui-datagrid" title="待選頻度" style="width:100%; height:270px; "
           data-options="singleSelect:true,collapsible:false,
                onDblClickRow:function(rowIndex, rowData){
                try{
                    winAddYz_PdConfirm();
                }
                catch(e){
                    alert('err:' + e.description);
                }
            }
            ">
        <thead>
        <tr>
            <th data-options="field:'dmmc',width:120,align:'left'">頻度名稱</th>
            <th data-options="field:'ldw',width:80,align:'center'">頻度拉丁文</th>
            <th data-options="field:'dm',width:80,align:'center'">頻度編碼</th>
        </tr>
        </thead>
    </table>
</div>
<div id="winAddYzPdBtn">
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:false" onclick="winAddYz_PdConfirm()">肯定</a>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$('#winAddYz_pd').window('close');">取消</a>
</div>

<!--詳情 主管科室:-->
<div id="xq_selKs" class="easyui-dialog" title="科室"
     data-options="modal:true,closed:true,resizable:true"
     style=" width:500px;height:300px;padding:10px;">

    <input id="xq_txtSearchKS" class="easyui-searchbox" style="width:100%;"
           data-options="searcher:xqSearchKs,prompt:'請輸入科室名或拼音碼查找科室'"></input>

    <div style="margin-top:10px;"></div>

    <!--//雙擊某一行選擇;設置值,關閉窗口-->
    <!--$("#bzxcdjy").textbox({"setValue":rowData.bzxcdjy}); //setText -->
    <!--//$("#f_kyxmxq").form("load",{bzxcdjy:rowData.bzxcdjy});-->
    <!---->
    <table id="xq_gridDXKS" class="easyui-datagrid" title="" style="width:100%; height:210px; "
           data-options="singleSelect:true,collapsible:false">
        <thead>
        <tr>
            <th data-options="field:'bmmc',width:360,align:'left'">部門名稱</th>
            <th data-options="field:'bmbm',width:80,align:'center'">部門編碼</th>
        </tr>
        </thead>
    </table>

</div>
<!--<div id="xq_winSelKsBtn">-->
    <!--<a id="xq_btnSaveKs" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:false" onclick="SaveKs()">保存</a>-->
    <!--<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$('#winSelKs').window('close');">取消</a>-->
<!--</div>-->

<!--詳情 主管醫生:-->
<div id="xq_selRy" class="easyui-dialog" title="人員"
     data-options="modal:true,closed:true,resizable:true"
     style=" width:500px;height:300px;padding:10px;">

    <input id="xq_txtSearchRY" class="easyui-searchbox" style="width:100%;"
           data-options="searcher:xqSearchRy,prompt:'請輸入工號、姓名或拼音碼查找人員'"></input>

    <div style="margin-top:10px;"></div>

    <!--//雙擊某一行選擇;設置值,關閉窗口-->
    <!--$("#bzxcdjy").textbox({"setValue":rowData.bzxcdjy}); //setText -->
    <!--//$("#f_kyxmxq").form("load",{bzxcdjy:rowData.bzxcdjy});-->
    <!--  -->
    <table id="xq_gridDXRY" class="easyui-datagrid" title="" style="width:100%; height:210px; "
           data-options="singleSelect:true,collapsible:false">
        <thead>
        <tr>
            <th data-options="field:'bmmc',width:180,align:'left'">部門名稱</th>
            <th data-options="field:'czydm',width:80,align:'center'">工號</th>
            <th data-options="field:'czyxm',width:80,align:'center'">姓名</th>
            <th data-options="field:'lxdh',width:100,align:'center'">聯繫電話</th>
        </tr>
        </thead>
    </table>

</div>

<script>
    var param = {};
    var editJdParam = {};



    $(function () {
        $("#xmmc").textbox('textbox').bind('click',function(){
            this.value = '';
        });

        $("#xmmc").textbox("textbox").bind('keyup',function (event) {
            if (event.which == 13) {
                find();
            }
        });

        // $("#ywmc").textbox('textbox').bind('click',function(){
        //     this.value = '';
        // });
        //
        // $("#syz").textbox('textbox').bind('click',function(){
        //     this.value = '';
        // });
        //
        // // $("#scxs").textbox('textbox').bind('click',function(){
        // //     this.value = '';
        // // });
        //
        // $("#sbz").textbox('textbox').bind('click',function(){
        //     this.value = '';
        // });
        //
        // $("#sbzlxdh").textbox('textbox').bind('click',function(){
        //     this.value = '';
        // });
        //
        // $("#cro").textbox('textbox').bind('click',function(){
        //     this.value = '';
        // });
        //
        // $("#crolxdh").textbox('textbox').bind('click',function(){
        //     this.value = '';
        // });
        //
        // $("#zzdw").textbox('textbox').bind('click',function(){
        //     this.value = '';
        // });
        //
        // $("#zzdwyjy").textbox('textbox').bind('click',function(){
        //     this.value = '';
        // });
        //
        //點擊輸入框,彈出選擇框
        // $("#bzxcdjy").textbox('textbox').bind('click',function(){
        //
        // });
        // //
        // $("#bzxcdjyyjy").textbox('textbox').bind('click',function(){
        //
        // });
        //
        // $("#jhls").textbox('textbox').bind('click',function(){
        //     this.value = '';
        // });
        //
        // $("#yyls").textbox('textbox').bind('click',function(){
        //     this.value = '';
        // });
        $("#zgks").textbox('textbox').bind('click',function(){
            if(!$("input[name='xq_xmbm']").val()){
                return;
            }
            xqSelKs();
        });
        //
        $("#zgys").textbox('textbox').bind('click',function(){
            if(!$("input[name='xq_xmbm']").val()){
                return;
            }
            xqSelRy();
        });
        //初始化 詳情下拉框
        genOptions("ywjx","108");
        genOptions("zcfl","286");
        genOptions("syfq","287");
        genOptions("lxlb","288");
        genOptions("scxs","289");

    });
    // a01:108 藥物劑型
    // a01:286 註冊分類
    // a01:287 試驗分期
    // a01:288 立項類別
    // a01:289 審查形式
    //DM,UNAME
    function genOptions(id,lxbm,selectText) {
        $("#" + id).html("");//先清空
        var showText = "";
        switch(lxbm){
            case "108":
                showText = "藥物劑型";
                break;
            case "286":
                showText = "註冊分類";
                break;
            case "287":
                showText = "試驗分期";
                break;
            case "288":
                showText = "立項類別";
                break;
            case "289":
                showText = "審查形式";
                break;
        }
        var data = {
            a01: lxbm
        };
        $.ajax({
            type: "GET",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            dataType: "json",
            url: "basetable/query.do",
            data: data, //規定要發送到服務器的數據
            success: function (data) {
                if(data.rows === "0"){
                    $.messager.alert('提示', showText + "信息", "info");
                }else if (data && data.rows) {
                    for(var i=0;i<data.rows.length;i++){
                        if(selectText === data.rows[i].uname){
                            $("#" + id).append('<option selected="selected" value="' + data.rows[i].dm + '">'+ data.rows[i].uname + '</option>');
                        }else{
                            $("#" + id).append('<option value="' + data.rows[i].dm + '">'+ data.rows[i].uname + '</option>');

                        }
                    }
                } else {
                    $.messager.alert('提示', showText + "信息異常", "error");
                }
            },
            error: function (xhr, status, error) {
                //XMLHttpRequest 對象、錯誤信息、(可選)捕獲的異常對象
                $.messager.alert('提示', showText + "信息加載失敗", "error");
            }
        })
    }


    function findJd(xmbm) {
        var param = {"a01":xmbm};
        $.ajax({
            type: "POST",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            dataType: "json",
            url: "stage/query.do",
            data: param, //規定要發送到服務器的數據
            success: function (data) {
                if(data.rows == "0"){
                    $('#t_jd').datagrid('loadData',{rows:[]});
                }else if (data && data.rows) {
                    $('#t_jd').datagrid('loadData', data);//Load local data, the old rows will be removed.
                } else {

                }
            },
            error: function (xhr, status, error) {
                //XMLHttpRequest 對象、錯誤信息、(可選)捕獲的異常對象

            }
        });
    }

    function saveJd() {
        var param = {};
        param.a01 = $("#jd_xmbm").val();
        param.a02 = $("#new_jdlx").val();
        param.a03 = ($("#newjd_fm input[name='jdmc']").val()).trim(); //newjd_fm


        if(!param.a01 || !param.a02 || !param.a03) return;
        $.ajax({
            type: "POST",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            dataType: "json",
            url: "stage/add.do",
            data: param,
            success: function (data) {
                if (data.state) {
                    $('#newjd_dlg').dialog('close');
                    findJd(param.a01);//刷新階段表格
                } else {
                    //成功返回數據,可是返回false ?
                    $.messager.alert({
                        title: 'Error',
                        msg: "添加失敗!"
                    });
                }
            },
            error: function (xhr, status, error) {
                // $('#new_dlg').dialog('close');
                $.messager.alert({
                    title: 'Error',
                    msg: "請求失敗:" + status
                });
            }
        });
    }


    function findXq(xmbm) {
        var param = {"a01":xmbm};
        $.ajax({
            type: "POST",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            dataType: "json",
            url: "projectdetail/query.do",
            data: param, //規定要發送到服務器的數據
            success: function (data) {
                if(!data){
                    $.messager.alert('提示', "加載項目詳情失敗!", "error");
                }else if (data && data.rows) {
                    $('#f_kyxmxq').form('load', data.rows[0]);
                    zgks = data.rows[0].zgks;
                    zgys = data.rows[0].zgys;
                    //form load 能加載 select 的 value
                }
            },
            error: function (xhr, status, error) {
                //XMLHttpRequest 對象、錯誤信息、(可選)捕獲的異常對象
                $.messager.alert('提示', "請求項目詳情失敗!", "error");
            }
        })
    }

    function saveXmxq(){
        var param = {};
        param.a01 = ($("input[name='xq_xmbm']").val());
        param.a02 = ($("input[name='cfdah']").val()).trim();
        param.a03 = ($("input[name='ywmc']").val()).trim();
        param.a04 =  $("#ywjx").val(); //加載的時候,select要設置value
        param.a05 = ($("input[name='syz']").val()).trim();
        param.a06 = $("#zcfl").val();


        param.a07 = $("#syfq").val();
        param.a08 = $("#lxlb").val();
        param.a09 = $("#scxs").val();
        param.a10 = ($("input[name='sbz']").val()).trim();
        param.a11 = ($("input[name='sbzlxdh']").val()).trim();
        param.a12 = ($("input[name='cro']").val()).trim();

        param.a13 = ($("input[name='crolxdh']").val()).trim();
        param.a14 = ($("input[name='zzdw']").val()).trim();
        param.a15 = ($("input[name='zzdwyjy']").val()).trim();
        param.a16 = ($("input[name='bzxcdjy']").val()).trim();
        param.a17 = ($("input[name='bzxcdjyyjy']").val()).trim();
        param.a18 = ($("input[name='jhls']").val()).trim();
        param.a19 = ($("input[name='yyls']").val()).trim();
        param.a20 = zgys;//主管醫生
        param.a21 = zgks;//主管科室
        //if(!(param.a01&&param.a02&&param.a03&&param.a04&&param.a05&&param.a06&&param.a07&&param.a08&&param.a09&&param.a10&&param.a11&&param.a12&&param.a13&&param.a14&&param.a15&&param.a16&&param.a17&&param.a18&&param.a19))
        //{
        //$.messager.alert('提示', "信息填寫不完整", "info");
        //return;
        //}

        if(!param.a01){
            return;
        }

        $.ajax({
            type: "POST",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            dataType: "json",
            url: "projectdetail/update.do",
            data: param,
            success: function (data) {
                if (data.state) {
                    $.messager.alert('提示', "保存成功!", "info");
                } else {
                    //成功返回數據,可是返回false ?
                    $.messager.alert({
                        title: 'Error',
                        msg: "保存失敗!"
                    });
                }
            },
            error: function (xhr, status, error) {
                // $('#new_dlg').dialog('close');
                $.messager.alert({
                    title: 'Error',
                    msg: "請求失敗:" + status
                });
            }
        });
    }

    function clearXq(){
        var xmbm = $("#xq_xmbm").val();
        $("#f_kyxmxq").form('clear');
        // $("#f_kyxmxq input").val('');
        // if(xmbm != ""){
        //     //id 選擇器才能修改顯示值;須要保留項目編號?
        //     $("#xq_xmbm").textbox({"value":xmbm});
        // }
    }

    function addStage() {
        var xmbm = $("#xq_xmbm").val();
        if(!xmbm) return;//沒有項目編碼,點擊新增階段無效
        $('#newjd_fm').form('clear');
        // $("#jd_xmbm").val(xmbm);//無效
        $('#newjd_fm').form('load', {"jd_xmbm":xmbm,"new_jdlx":"1"});
        // $("#jd_xmbm").textbox({"value":xmbm});//input 框第二次塌陷
        // $("#new_jdlx").val("1");//爲 階段類型 下拉框 初始化一個值
        $('#newjd_dlg').dialog('open').dialog('center').dialog('setTitle', '新增階段');

    }

    function editStage() {
        var row = $('#t_jd').datagrid('getSelected');//Return the first selected row record or null.
        if (row) {
            //row 會包含load到全部數據,即便field中沒有
            editJdParam.a01 = row.id;  //階段 id
            $('#editjd_fm').form('load', row);//對話框中的form加載選擇row的內容
            // var xmbm = $("#xq_xmbm").val(); // row.xmbm ??
            // $("#editjd_xmbm").textbox({"value":xmbm});//項目編碼能夠 自動加載!
            $("#edit_jdlx").val(row.jdlx);
            $('#editjd_dlg').dialog('open').dialog('center').dialog('setTitle', '修改階段');
        }

    }

    function saveEditJd() {

        editJdParam.a02 =  $("#editjd_xmbm").val(); //項目編碼
        // editJdParam.a03 = ($("#edit_xh").val()).trim(); //序號
        editJdParam.a03= $("#edit_jdlx").val(); //階段類型 select
        editJdParam.a04= ($("#edit_jdmc").val()).trim();  //階段名稱
        if(!(editJdParam.a01&&editJdParam.a02&&editJdParam.a03&&editJdParam.a04)){
            return;
        }
        $.ajax({
            type: "POST",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            dataType: "json",
            url: "stage/update.do",
            data: editJdParam,
            success: function (result) {
                if (result.state) {
                    $('#editjd_dlg').dialog('close');
                    findJd(editJdParam.a02);
                } else {
                    //成功返回數據,可是返回false ?
                    $.messager.alert({
                        title: 'Error',
                        msg: "修改失敗!"
                    });
                }
            },
            error: function (xhr, status, error) {
                // $('#edit_dlg').dialog('close');
                $.messager.alert({
                    title: 'Error',
                    msg: "請求失敗:" + status
                });
            }
        })
    }

    function deleteStage() {
        var row = $('#t_jd').datagrid('getSelected');
        if (row) {
            var id = row.id;
            var xmbm = row.xmbm;
            $.messager.confirm('提示', "是否刪除該階段?", function (r) {
                if (r) {
                    //傳遞選中行數據
                    $.post('stage/delete.do', {a01: xmbm,a02:id}, function (result) {
                        if (result.state) {
                            $.messager.alert({
                                title: 'Success',
                                msg: "刪除成功!"
                            });
                            findJd(xmbm);   // reload the user data
                        } else {
                            $.messager.alert({    // show error message
                                title: 'Error',
                                msg: "刪除失敗:" + result.errorMsg
                            });
                        }
                    }, 'json');
                }
            });
        }

    }


    $("#t_jd").datagrid(
        {
            columns:[[
                //
                {
                    field:'id',
                    width:100,
                    hidden : 'true',
                    title:"ID"
                },
                {
                    field:'xmbm',
                    width:100,
                    title:"項目編碼",
                    hidden : 'true'
                },
                {
                    field:'xh',
                    width:100,
                    title:"序號"
                },
                {
                    field:'jdmc',
                    width:100,
                    title:"階段名稱"
                },
                {
                    field:'jdlx',
                    width:100,
                    title:"階段類型",
                    formatter: function(value,row,index){
                        var text;
                        if(row.jdlx === "1"){
                            text = "篩選階段";
                        }else if(row.jdlx === "2"){
                            text = "治療階段";
                        }else{
                            text = "隨訪階段";
                        }
                        return text;//只改變顯示,表格值不變
                    }
                } ,
                {
                    field:'yzwh',
                    width:100,
                    title:"醫囑維護",
                    formatter: function(value,row,index){
                        // 階段名稱 關聯 醫囑?
                        return '<a style="color:blue;text-decoration: none" onclick="SelYz(' + row.id + ')">醫囑維護</a>';
                    }
                }
            ]]
        }
    );



    $('#t_kyxm').datagrid({
        //雙擊某行
        onDblClickRow: function(index,row){
            if(row){
                // $("#main").layout("expand","east");
                // $('#f_kyxmxq').form('load', row);
                var xmbm = row.xmbm;
                $("#xq_xmbm").textbox({"value":xmbm});
                findXq(xmbm);
                findJd(xmbm);

            }
        },
        columns:[[
            {
                field:'xmbm',
                width:100,
                title:"項目編碼"
            },
            {
                field:'xmmc',
                width:100,
                title:"項目名稱"
            },
            {
                field:'kydwmc',
                width:100,
                title:"科研單位"
            },
            {
                field:'xmlx',
                width:100,
                title:"項目類型",
                formatter:function (value,row,index) {
                    switch(value){
                        case '1':
                            return '藥物臨牀試驗';
                            break;
                        case '2':
                            return '醫療器械臨牀試驗';
                            break;
                        case '3':
                            return '診斷試劑臨牀試驗';
                            break;
                        case '4':
                            return '其餘';
                            break;
                        default:
                            return '';
                    }
                }
            },
            {
                field:'fylx',
                title:"報銷類型",
                width:80,
                formatter:function (value,row,index) {
                    switch (value){
                        case "1":
                            return "所有報銷";
                            break;
                        case "2":
                            return "部分報銷";
                            break;
                        case "3":
                            return "手工報銷";
                            break;
                        default:
                            return "";
                    }
                }
            },
            {
                field:'zt',
                width:100,
                title:"項目狀態",
                formatter: function(value,row,index){
                    switch (value){
                        case '1':
                            return '申請';
                            break;
                        case '2':
                            return '已審批';
                            break;
                        case '3':
                            return '已做廢';
                            break;
                        default:
                            return '';
                    }
                }
            },
            {
                field:'yxrq',
                width:100,
                title:"立項日期"
            },
            {
                field:'zbrq',
                width:150,
                title:"製表日期"
            },
            {
                field:'cyks',
                width:90,
                title:"參與科室",
                formatter: function(value,row,index){
                    return '<a style="color:blue;text-decoration: none" onclick="SelKs(' + row.xmbm + ')">科室維護</a>';
                }
            },
            {
                field:'cyry',
                width:90,
                title:"參與人員",
                formatter: function(value,row,index){
                    return '<a style="color:blue;text-decoration: none" onclick="SelRy(' + row.xmbm + ')">人員維護</a>';
                }
            }
        ]]
    });

    function dataToText(data){
        var rows = data.rows;
        var text = [];
        var row;
        if(rows){
            for(var i=0;i<rows.length;i++){
                row = {};
                row["xmbm"] = rows[i]["xmbm"];
                row["kydwmc"] = rows[i]["kydwmc"];
                row["xmlx"] = rows[i]["xmlx"];
                row["xmmc"] = rows[i]["xmmc"];
                row["yxrq"] = rows[i]["yxrq"];
                row["zbrq"] = rows[i]["zbrq"];
                if(rows[i]["zt"] === "0"){
                    row["zt"] = "禁用";
                }else{
                    row["zt"] = "可用";
                }
                text.push(row);
            }
            return text;
        }else{
            return null;
        }
    }

    //科研單位 下拉項
    function genKydwmc(id,selectedText) {
        $("#" + id).html("");//先清空
        var data = {
            a01: "",
            a02: "",
            a03: "all"
        };
        $.ajax({
            type: "POST",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            dataType: "json",
            url: "company/query.do",
            data: data, //規定要發送到服務器的數據
            success: function (data) {
                if(data.rows === "0"){
                    $.messager.alert('提示', "尚無科研單位", "info");
                }else if (data && data.rows) {
                    for(var i=0;i<data.rows.length;i++){
                        if(selectedText === data.rows[i].dwmc){
                            $("#" + id).append('<option selected="selected" value="' + data.rows[i].dwbm + '">'+ data.rows[i].dwmc + '</option>');
                        }else{
                            $("#" + id).append('<option value="' + data.rows[i].dwbm + '">'+ data.rows[i].dwmc + '</option>');

                        }
                    }
                } else {
                    $.messager.alert('提示', "科研單位信息異常", "error");
                }
            },
            error: function (xhr, status, error) {
                //XMLHttpRequest 對象、錯誤信息、(可選)捕獲的異常對象
                $.messager.alert('提示', "科研單位信息加載失敗", "error");
            }
        })
    }

    //新增 科研項目
    function saveNew() {
        var param = {};
        param.a01 = ($("input[name='new_xmmc']").val()).trim();//項目名稱
        param.a02 = $("#new_kydwmc").val();//科研單位 編碼
        param.a03 = $("#new_xmlx").val();//項目類型
        param.a04 = ($("input[name='new_yxrq']").val()).trim();//立項日期
        param.a05 = $("#new_fylx").val();//fylx 報銷類型
        if(!param.a01 || !param.a02 || !param.a03 || !param.a04) return;
        $.ajax({
            type: "POST",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            dataType: "json",
            url: "project/add.do",
            data: param,
            success: function (data) {
                if (data.state) {
                    $('#new_dlg').dialog('close');
                    findAll();
                } else {
                    //成功返回數據,可是返回false ?
                    $.messager.alert({
                        title: 'Error',
                        msg: "添加失敗!"
                    });
                }
            },
            error: function (xhr, status, error) {
                // $('#new_dlg').dialog('close');
                $.messager.alert({
                    title: 'Error',
                    msg: "請求失敗:" + status
                });
            }
        });
    }

    function findAll() {
        var data = {
            a01: "",
            a02: "all"
        };
        $.ajax({
            type: "POST",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            dataType: "json",
            url: "project/query.do",
            data: data, //規定要發送到服務器的數據
            success: function (data) {
                if(data.rows == "0"){

                }else if (data && data.rows) {
                    $('#t_kyxm').datagrid('loadData', data);//Load local data, the old rows will be removed.
                } else {

                }
            },
            error: function (xhr, status, error) {
                //XMLHttpRequest 對象、錯誤信息、(可選)捕獲的異常對象

            }
        })

    }

    //查詢
    function find() {
        var xmmc = ($("#xmmc").val()).trim();
        var zt = $("#zt").val();

        var data = {
            a01: xmmc,
            a02: zt
        };
        $.ajax({
            type: "POST",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            dataType: "json",
            url: "project/query.do",
            data: data, //規定要發送到服務器的數據
            success: function (data) {
                if(data.rows === "0"){
                    $.messager.alert('提示', "沒有查詢到符合條件的項目", "info");
                }else if (data && data.rows) {
                    $('#t_kyxm').datagrid('loadData', data);//Load local data, the old rows will be removed.
                } else {
                    $.messager.alert('Error', "返回數據格式有誤!", "error");
                }
            },
            error: function (xhr, status, error) {
                //XMLHttpRequest 對象、錯誤信息、(可選)捕獲的異常對象
                $.messager.alert('Error', "查詢數據失敗!", "error");
            }
        })

    }

    function deleteXm() {
        var row = $('#t_kyxm').datagrid('getSelected');
        if (row) {
            switch (row.zt){
                case '1':
                    text =  '申請';
                    break;
                case '2':
                    text = '已審批';
                    $.messager.alert('提示', "項目" + text + ",不可刪除", "info");
                    return;
                case '3':
                    text = '已做廢';
                    $.messager.alert('提示', "項目" + text + ",不可刪除", "info");
                    return;
            }
            var xmbm = row.xmbm;
            $.messager.confirm('提示', "是否刪除該項目?", function (r) {
                if (r) {
                    //傳遞選中行數據
                    $.post('project/delete.do', {a01: xmbm}, function (result) {
                        if (result.state) {
                            $.messager.alert({
                                title: 'Success',
                                msg: "刪除成功!"
                            });
                            findAll();   // reload the user data
                        } else {
                            $.messager.alert({    // show error message
                                title: 'Error',
                                msg: "刪除失敗:" + result.errorMsg
                            });
                        }
                    }, 'json');
                }
            });
        }
    }

    function newXm() {
        $('#new_fm').form('clear');
        // $('#new_fm input').val('');
        $('#new_fm').form('load', {"fylx":"1","new_xmlx":"1"});//爲下拉框賦默認值
        genKydwmc("new_kydwmc");
        $('#new_dlg').dialog('open').dialog('center').dialog('setTitle', '添加');
        // $("#new_zt").val("0");//初始化狀態爲 新建
        //點保存saveUser()的以後纔會從fm的form提交到數據庫
    }

    //修改
    function editXm() {
        var row = $('#t_kyxm').datagrid('getSelected');//Return the first selected row record or null.
        if (row) {
            var text ;
            switch (row.zt){
                case '1':
                    text =  '申請';
                    break;
                case '2':
                    text = '已審批';
                    $.messager.alert('提示', "項目" + text + ",不可修改", "info");
                    return;
                case '3':
                    text = '已做廢';
                    $.messager.alert('提示', "項目" + text + ",不可修改", "info");
                    return;
            }
            param.a01 = row.xmbm;//修改的時候,保存原來的項目編碼
            genKydwmc("edit_kydwmc",row.kydwmc);//append延遲添加了,因此選不到
            $('#edit_dlg').dialog('open').dialog('center').dialog('setTitle', '修改');
            $('#edit_fm').form('load', row);//對話框中的form加載選擇row的內容
        }
    }


    function saveEdit() {
        param.a02 = ($("input[name='xmmc']").val()).trim();
        param.a03 = $("#edit_kydwmc").val();//單位名稱???
        param.a04 = $("#edit_xmlx").val();
        param.a05 = ($("input[name='yxrq']").val()).trim();
        param.a06 = $("#edit_fylx").val();//fylx 報銷類型
        param.a07 = $("#edit_zt").val();
        if(!(param.a01&&param.a02&&param.a03&&param.a04&&param.a05)){
            return;
        }
        $.ajax({
            type: "POST",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            dataType: "json",
            url: "project/update.do",
            data: param,
            success: function (result) {
                if (result.state) {
                    $('#edit_dlg').dialog('close');
                    findAll();
                } else {
                    //成功返回數據,可是返回false ?
                    $.messager.alert({
                        title: 'Error',
                        msg: "修改失敗!"
                    });
                }
            },
            error: function (xhr, status, error) {
                // $('#edit_dlg').dialog('close');
                $.messager.alert({
                    title: 'Error',
                    msg: "請求失敗:" + status
                });
            }
        })
    }



    function closeDlg(id) {
        $('#' + id).dialog('close');
    }

    // 人員 科室
    var iGyid = ""; //當前選擇的項目ID

    var iJdid = ""; //階段ID

    var allRyData = [];
    var selRyData = [];

    var allKsData = [];
    var selKsData = [];
    var allYzData = [];
    var selYzData = [];

    var allYfData = [];
    var allPdData = [];

    function getData(strType) {
        //$.messager.progress();
        var strUrl = "";
        switch(strType)
        {
            case "selRy": //選擇的人員
                selRyData = [];
                strUrl = "inworkers/query.do";
                break;
            case "allRy": //全部人員
                if (allRyData.length > 0)
                    return;
                //allRyData = [];
                strUrl = "workers/query.do";
                break;
            case "selKs": //選擇的科室
                selKsData = [];
                strUrl = "indepartment/query.do";
                break;
            case "allKs": //全部科室
                if (allKsData.length > 0)
                    return;

                //allKsData = [];
                strUrl = "department/query.do";
                break;

            case "selYz": //選擇的醫囑
                selYzData = [];
                strUrl = "stageadvice/query.do";
                break;
            case "allYz": //全部醫囑
                if (allYzData.length > 0)
                    return;

                strUrl = "doctoradvice/query.do";
                break;
            case "allYf": //用法
                if (allYfData.length > 0)
                    return;

                strUrl = "basetable/query.do";
                break;
            case "allPd": //頻度
                if (allPdData.length > 0)
                    return;
                strUrl = "frequency/query.do";
                break;
        }

        var param = {};
        param.a01 = iGyid;
        if (strType == "selYz")
            param.a01 = iJdid;
        else if (strType == "allYf")
            param.a01 = "109";

        $.ajax({
            type: "get",
            contentType: "application/json; charset=UTF-8",
            dataType: "json",
            url: strUrl,
            data: param,
            success: function (data) {
                if (data && data.rows) {
                    switch(strType)
                    {
                        case "selRy": //選擇的人員
                            selRyData = data.rows;
                            //alert("sel " + selRyData.length);

                            $('#gridYXRY').datagrid({
                                data:selRyData
                            });
                            //$('#gridYXRY').datagrid('loadData', selRyData);
                            break;
                        case "allRy": //全部人員
                            allRyData = data.rows;
                            //alert("all " + allRyData.length);

                            $('#gridDXRY').datagrid({
                                data:allRyData
                            });
                            //$('#gridYXRY').combogrid('loadData', allRyData);
                            break;

                        case "selKs": //選擇的科室
                            selKsData = data.rows;
                            //alert("sel " + selKsData.length);

                            $('#gridYXKS').datagrid({
                                data:selKsData
                            });
                            break;
                        case "allKs": //全部科室
                            allKsData = data.rows;
                            //alert("all " + allKsData.length);

                            $('#gridDXKS').datagrid({
                                data:allKsData
                            });

                            $('#gridAddDXKS').datagrid({
                                data:allKsData
                            });
                            break;
                        case "selYz": //選擇的醫囑
                            selYzData = data.rows;
                            try
                            {
                                for (var iSelYzData = 0; iSelYzData < selYzData.length; iSelYzData++)
                                {
                                    selYzData[iSelYzData].jzfsmc = selYzData[iSelYzData].jzfs == "1" ? "" : "";
                                    selYzData[iSelYzData].bzxmmc = selYzData[iSelYzData].bzxm == "1" ? "" : "";
                                    selYzData[iSelYzData].kybzmc = selYzData[iSelYzData].kybz == "1" ? "" : "";
                                }
                            }
                            catch (e)
                            {
                                alert(e.description);
                            }
                            $('#gridYXYZ').datagrid({
                                data:selYzData
                            });
                            break;
                        case "allYz": //全部醫囑
                            allYzData = data.rows;
                            $('#gridAddDXYZ').datagrid({
                                data:allYzData
                            });
                            break;
                        case "allYf": //用法
                            allYfData = data.rows;
                            $('#gridAddDXYF').datagrid({
                                data:allYfData
                            });
                            break;
                        case "allPd": //頻度
                            allPdData = data.rows;
                            $('#gridAddDXPD').datagrid({
                                data:allPdData
                            });
                            break;
                    }
                }
            },
            error: function (xhr, status, error) {
                //XMLHttpRequest 對象、錯誤信息、(可選)捕獲的異常對象
                alert("err: " + error + " status:" + status);
            }
        });
    }

    function SelRy(xmbm)
    {
        //if (allRyData.length == 0)
        iGyid = xmbm;
        getData("allRy");
        getData("selRy");
        $('#winSelRy').window('open').window('center');
    }

    function SearchRy(value,name)
    {
        //alert(value + " " + name);
        try{
            var filterDxryData = [];
            if (value.trim().length > 0)
            {
                for(var i = 0; i < allRyData.length; i++)
                {
                    if (allRyData[i]['czydm'].indexOf(value) >= 0 || nullToEmpty(allRyData[i]['czyxm']).indexOf(value) >= 0 || nullToEmpty(allRyData[i]['pym']).toLowerCase().indexOf(value.toLowerCase()) >= 0)
                    {
                        filterDxryData.push(allRyData[i]);
                    }
                }
            }
            else
                filterDxryData = allRyData;

            $('#gridDXRY').datagrid({
                data:filterDxryData
            });
        }
        catch(e){
            alert('err:' + e.description);
        }
    }

    function SaveRy()
    {
        var param = {};
        param.a01 = iGyid;

        param.a02 = "";
        for(var i = 0; i < selRyData.length; i++)
            param.a02 += selRyData[i].czydm + ",";
        alert(param.a02);
        if(!param.a01)
        {
            alert("未選擇指定項目");
            return;
        }
        $.ajax({
            type: "POST",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            dataType: "json",
            url: "inworkers/add.do",
            data: param,
            success: function (data) {
                if (data.state) {
                    $('#winSelRy').dialog('close');
                } else {
                    //成功返回數據,可是返回false ?
                    $.messager.alert({
                        title: 'Error',
                        msg: "添加失敗!"
                    });
                }
            },
            error: function (xhr, status, error) {
                // $('#new_dlg').dialog('close');
                $.messager.alert({
                    title: 'Error',
                    msg: "請求失敗:" + status
                });
            }
        });
    }

    function SelKs(xmbm)
    {
        iGyid = xmbm;
        getData("allKs");
        getData("selKs");
        $('#winSelKs').window('open').window('center');
    }

    function SearchKs(value,name)
    {
        //alert(value + " " + name);
        try{
            var filterDxksData = [];
            if (value.trim().length > 0)
            {
                for(var i = 0; i < allKsData.length; i++)
                {
                    if (allKsData[i]['bmbm'].indexOf(value) >= 0 || allKsData[i]['bmmc'].indexOf(value) >= 0 || nullToEmpty(allKsData[i]['pym']).toLowerCase().indexOf(value.toLowerCase()) >= 0)
                    {
                        filterDxksData.push(allKsData[i]);
                    }
                }
            }
            else
                filterDxksData = allKsData;

            $('#gridDXKS').datagrid({
                data:filterDxksData
            });
        }
        catch(e){
            alert('err:' + e.description);
        }
    }


    function SaveKs()
    {
        var param = {};
        param.a01 = iGyid;

        param.a02 = "";
        for(var i = 0; i < selKsData.length; i++)
            param.a02 += selKsData[i].bmbm + ",";
        alert(param.a02);
        if(!param.a01)
        {
            alert("未選擇指定項目");
            return;
        }
        $.ajax({
            type: "POST",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            dataType: "json",
            url: "indepartment/add.do",
            data: param,
            success: function (data) {
                if (data.state) {
                    $('#winSelKs').dialog('close');
                } else {
                    //成功返回數據,可是返回false ?
                    $.messager.alert({
                        title: 'Error',
                        msg: "添加失敗!"
                    });
                }
            },
            error: function (xhr, status, error) {
                // $('#new_dlg').dialog('close');
                $.messager.alert({
                    title: 'Error',
                    msg: "請求失敗:" + status
                });
            }
        });
    }

    //醫囑
    function SelYz(jdid)
    {
        iJdid = jdid;
        getData("allYz");
        getData("selYz");
        getData("allKs");
        getData("allYf");
        getData("allPd");
        $('#winSelYz').window('open').window('center');
    }

    function SearchAddYz(value,name)
    {
        //alert(value + " " + name);
        try{
            var filterDxyzData = [];
            if (value.trim().length > 0)
            {
                for(var i = 0; i < allYzData.length; i++)
                {
                    if (allYzData[i]['dmmc'].indexOf(value) >= 0 || allYzData[i]['yzfl'].indexOf(value) >= 0 || nullToEmpty(allYzData[i]['pym']).toLowerCase().indexOf(value.toLowerCase()) >= 0)
                    {
                        filterDxyzData.push(allYzData[i]);
                    }
                }
            }
            else
                filterDxyzData = allYzData;

            $('#gridAddDXYZ').datagrid({
                data:filterDxyzData
            });
        }
        catch(e){
            alert('err:' + e.description);
        }
    }

    var rowDataYz; //階段醫囑的一條數據
    var iJdYzModifyType;
    function NewYz(iType)
    {
        try
        {
            rowDataYz = {};
            iJdYzModifyType = iType;
            $('#formAddYz').form('clear');
            $('#ctrl_KYBZ').prop("checked", true);

            if (iType == 1)
            {
                //修改醫囑
                var selRow = $('#gridYXYZ').datagrid('getSelected');
                if (selRow == null)
                {
                    alert("請先選擇需編輯的行");
                    return;
                }
                rowDataYz = selRow;
                $('#ctrl_XH').numberspinner('setValue', rowDataYz.xh);
                $('#ctrl_YZLB').val(rowDataYz.yzlb);
                $('#ctrl_YZMC').val(rowDataYz.yzmc);
                $('#ctrl_ZXKS').val(rowDataYz.zxks);
                $('#ctrl_ZXKSMC').val(rowDataYz.zxksmc);

                $('#ctrl_JZFS').prop("checked",rowDataYz.jzfs == "1" ? true : false);
                $('#ctrl_BZXM').prop("checked",rowDataYz.bzxm == "1" ? true : false);
                $('#ctrl_KYBZ').prop("checked",rowDataYz.kybz == "1" ? true : false);
                $('#ctrl_JL').numberbox('setValue', rowDataYz.jl);
                $('#ctrl_YFMC').val(rowDataYz.yfmc);
                $('#ctrl_YFSM').val(rowDataYz.yfsm);
                $('#ctrl_PDLDW').val(rowDataYz.pdldw);
                $('#ctrl_PDMC').val(rowDataYz.pdmc);

                $('#ctrl_TS').numberspinner('setValue', rowDataYz.ts);
                $('#ctrl_ZSL').numberbox('setValue', rowDataYz.zsl);
            }
            else if (iType == 2)
            {
                //刪除
                if (window.confirm('確認要刪除本條醫囑?'))
                    SaveYz();
                return;
            }
            $('#winAddYz').window('open').window('center');
        }
        catch (e)
        {
            alert("出錯:" + e.description);
        }
    }

    function SaveYz()
    {
        try
        {
            var strUrl = "stageadvice/add.do";
            if (iJdYzModifyType == 1 || iJdYzModifyType == 2)
            {
                var selRow = $('#gridYXYZ').datagrid('getSelected');
                if (selRow == null)
                {
                    alert("請先選擇醫囑!");
                    return;
                }
                rowDataYz.id = selRow.id;
                if (iJdYzModifyType == 1)
                    strUrl = "stageadvice/update.do";
                else if (iJdYzModifyType == 2)
                    strUrl = "stageadvice/delete.do";
            }
            else
                rowDataYz.id = "0";

            rowDataYz.gyid = iJdid;
            rowDataYz.xh = $('#ctrl_XH').numberspinner('getValue');
            if (rowDataYz.xh.length == 0 && iJdYzModifyType != 2)
            {
                alert("您未指定序號,請返回檢查");
                return;
            }
            //rowDataYz.yzlb = $('#ctrl_YZLB').val();
            //rowDataYz.yzdm = $('#ctrl_YZDM').val();
            rowDataYz.jzfs = $('#ctrl_JZFS').is(':checked') ? 1 : 0;
            rowDataYz.bzxm = $('#ctrl_BZXM').is(':checked') ? 1 : 0;
            rowDataYz.kybz = $('#ctrl_KYBZ').is(':checked') ? 1 : 0;
            //rowDataYz.yzmc = $('#ctrl_YZMC').val();
            //rowDataYz.zxks = $('#ctrl_ZXKS').val();
            rowDataYz.jl = $('#ctrl_JL').numberbox('getValue');
            if (rowDataYz.jl.length == 0)
                rowDataYz.jl = 0;
            //rowDataYz.yf = $('#ctrl_YF').val();
            rowDataYz.yfsm = $('#ctrl_YFSM').val();
            //rowDataYz.pd = $('#ctrl_PD').val();
            rowDataYz.ts = $('#ctrl_TS').numberspinner('getValue');
            if (rowDataYz.ts.length == 0)
                rowDataYz.ts = 0;
            rowDataYz.zsl = $('#ctrl_ZSL').numberbox('getValue');
            if (rowDataYz.zsl.length == 0)
                rowDataYz.zsl = 0;

            var param = {};
            param.A01 = rowDataYz.id;
            param.A02 = rowDataYz.gyid;
            param.A03 = rowDataYz.xh;
            param.A04 = rowDataYz.yzlb;
            param.A05 = rowDataYz.yzdm;
            param.A06 = rowDataYz.jzfs;
            param.A07 = rowDataYz.bzxm;
            param.A08 = rowDataYz.kybz;
            param.A09 = rowDataYz.yzmc;
            param.A10 = rowDataYz.zxks;
            param.A11 = rowDataYz.jl;
            param.A12 = rowDataYz.yf;
            param.A13 = rowDataYz.yfsm;
            param.A14 = rowDataYz.pd;
            param.A15 = rowDataYz.ts;
            param.A16 = rowDataYz.zsl;

            $.ajax({
                type: "POST",
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                dataType: "json",
                url: strUrl,
                data: param,
                success: function (data) {
                    if (data.state) {
                        $('#winAddYz').dialog('close');
                        $('#formAddYz').form('clear');
                        getData("selYz");
                    } else {
                        $.messager.alert({
                            title: 'Error',
                            msg: "操做失敗!"
                        });
                    }
                },
                error: function (xhr, status, error) {
                    // $('#new_dlg').dialog('close');
                    $.messager.alert({
                        title: 'Error',
                        msg: "請求失敗:" + status
                    });
                }
            });
        }
        catch (e)
        {
            alert("出錯:" + e.description);
        }
    }

    function winAddYz_YzConfirm()
    {
        var selRow = $('#gridAddDXYZ').datagrid('getSelected');
        if (selRow == null)
        {
            alert("請先選擇醫囑!");
            return;
        }
        rowDataYz.yzlb = selRow.yzfl;
        rowDataYz.yzmc = selRow.dmmc;
        rowDataYz.yzdm = selRow.dm;

        $('#ctrl_YZLB').val(selRow.yzfl);
        $('#ctrl_YZMC').val(selRow.dmmc);

        rowDataYz.zxks = selRow.mrzxks;
        $('#ctrl_ZXKS').val(selRow.mrzxks);
        $('#ctrl_ZXKSMC').val(selRow.mrzxksmc);

        $('#winAddYz_yz').window('close');
    }

    function SearchAddKs(value,name)
    {
        //alert(value + " " + name);
        try{
            var filterDxksData = [];
            if (value.trim().length > 0)
            {
                for(var i = 0; i < allKsData.length; i++)
                {
                    if (allKsData[i]['bmbm'].indexOf(value) >= 0 || allKsData[i]['bmmc'].indexOf(value) >= 0 || nullToEmpty(allKsData[i]['pym']).toLowerCase().indexOf(value.toLowerCase()) >= 0)
                    {
                        filterDxksData.push(allKsData[i]);
                    }
                }
            }
            else
                filterDxksData = allKsData;

            $('#gridAddDXKS').datagrid({
                data:filterDxksData
            });
        }
        catch(e){
            alert('err:' + e.description);
        }
    }

    function winAddYz_KsConfirm()
    {
        var selRow = $('#gridAddDXKS').datagrid('getSelected');
        if (selRow == null)
        {
            alert("請先選擇科室!");
            return;
        }
        rowDataYz.zxks = selRow.bmbm;

        $('#ctrl_ZXKS').val(selRow.bmbm);
        $('#ctrl_ZXKSMC').val(selRow.bmmc);

        $('#winAddYz_ks').window('close');
    }


    function SearchAddYf(value,name)
    {
        //alert(value + " " + name);
        try{
            var filterDxyfData = [];
            if (value.trim().length > 0)
            {
                for(var i = 0; i < allYfData.length; i++)
                {
                    if (allYfData[i]['uname'].indexOf(value) >= 0 || allYfData[i]['dm'] == value)
                    {
                        filterDxyfData.push(allYfData[i]);
                    }
                }
            }
            else
                filterDxyfData = allYfData;

            $('#gridAddDXYF').datagrid({
                data:filterDxyfData
            });
        }
        catch(e){
            alert('err:' + e.description);
        }
    }
    function winAddYz_YfConfirm()
    {
        var selRow = $('#gridAddDXYF').datagrid('getSelected');
        if (selRow == null)
        {
            alert("請先選擇用法!");
            return;
        }
        rowDataYz.yf = selRow.dm;

        $('#ctrl_YFMC').val(selRow.uname);

        $('#winAddYz_yf').window('close');
    }

    function SearchAddPd(value,name)
    {
        //alert(value + " " + name);
        try{
            var filterDxpdData = [];
            if (value.trim().length > 0)
            {
                for(var i = 0; i < allPdData.length; i++)
                {
                    if (allPdData[i]['dmmc'].indexOf(value) >= 0 || allPdData[i]['dm'] == value || nullToEmpty(allPdData[i]['ldw']).toLowerCase().indexOf(value.toLowerCase()) >= 0 )
                    {
                        filterDxpdData.push(allPdData[i]);
                    }
                }
            }
            else
                filterDxpdData = allPdData;

            $('#gridAddDXPD').datagrid({
                data:filterDxpdData
            });
        }
        catch(e){
            alert('err:' + e.description);
        }
    }
    function winAddYz_PdConfirm()
    {
        var selRow = $('#gridAddDXPD').datagrid('getSelected');
        if (selRow == null)
        {
            alert("請先選擇頻度!");
            return;
        }
        rowDataYz.pd = selRow.dm;

        $('#ctrl_PDLDW').val(selRow.ldw);
        $('#ctrl_PDMC').val(selRow.dmmc);

        $('#winAddYz_pd').window('close');
    }

    function nullToEmpty(value)
    {
        if (value == null || value == undefined )
            return "";
        return value;
    }

    var xqAllKsData = [];
    var xqAllRyData = [];
    var zgys = '';
    var zgks = '';

    $("#xq_gridDXKS").datagrid({
        onDblClickRow: function(rowIndex, rowData){
            // $('#zgks').textbox({'value':rowData.bmmc});//塌陷,點不到了?
            $("#f_kyxmxq").form("load",{zgksmc:rowData.bmmc});
            zgks = rowData.bmbm;
            closeDlg('xq_selKs');
        }
    });

    $("#xq_gridDXRY").datagrid({
        onDblClickRow:function(rowIndex, rowData){
            // $('#zgys').textbox({'value':rowData.czyxm});
            $("#f_kyxmxq").form("load",{zgysxm:rowData.czyxm});
            zgys = rowData.czydm;
            closeDlg('xq_selRy');
        }
    });

    function xqSearchKs(value,name)
    {
        //alert(value + " " + name);
        try{
            var filterDxksData = [];//過濾後的科室
            if (value.trim().length > 0)
            {
                for(var i = 0; i < allKsData.length; i++)
                {
                    if (allKsData[i]['bmbm'].indexOf(value) >= 0 || allKsData[i]['bmmc'].indexOf(value) >= 0 || nullToEmpty(allKsData[i]['pym']).toLowerCase().indexOf(value.toLowerCase()) >= 0)
                    {
                        filterDxksData.push(allKsData[i]);
                    }
                }
            }
            else
                filterDxksData = allKsData;

            $('#xq_gridDXKS').datagrid({
                data:filterDxksData
            });
        }
        catch(e){
            alert('err:' + e.description);
        }
    }

    function xqSearchRy(value,name)
    {
        //alert(value + " " + name);
        try{
            var filterDxryData = [];
            if (value.trim().length > 0)
            {
                for(var i = 0; i < xqAllRyData.length; i++)
                {
                    if (xqAllRyData[i]['czydm'].indexOf(value) >= 0 || nullToEmpty(xqAllRyData[i]['czyxm']).indexOf(value) >= 0 || nullToEmpty(xqAllRyData[i]['pym']).toLowerCase().indexOf(value.toLowerCase()) >= 0)
                    {
                        filterDxryData.push(xqAllRyData[i]);
                    }
                }
            }
            else
                filterDxryData = xqAllRyData;

            $('#xq_gridDXRY').datagrid({
                data:filterDxryData
            });
        }
        catch(e){
            alert('err:' + e.description);
        }
    }

    function xqSelKs()
    {
        getXqData("allKs");
        $('#xq_selKs').window('open').window('center');
        // $('#zgks').textbox({'value':"aaaaaa"});//能改變顯示
    }

    function xqSelRy()
    {
        getXqData("allRy");
        $('#xq_selRy').window('open').window('center');
        // $('#zgks').textbox({'value':"aaaaaa"});//能改變顯示
    }

    function getXqData(strType) {
        //$.messager.progress();
        var strUrl = "";
        switch(strType)
        {
            case "allRy": //全部人員
                if (xqAllRyData.length > 0)
                    return;
                //allRyData = [];
                strUrl = "workers/query.do";
                break;
            case "allKs": //全部科室
                if (xqAllKsData.length > 0)
                    return;

                //allKsData = [];
                strUrl = "department/query.do";
                break;

        }

        $.ajax({
            type: "get",
            contentType: "application/json; charset=UTF-8",
            dataType: "json",
            url: strUrl,
            success: function (data) {
                if (data && data.rows) {
                    switch(strType)
                    {

                        case "allRy": //全部人員
                            xqAllRyData = data.rows;
                            //alert("all " + allRyData.length);

                            $('#xq_gridDXRY').datagrid({
                                data:xqAllRyData
                            });
                            break;
                        case "allKs": //全部科室
                            xqAllKsData = data.rows;
                            //alert("all " + allKsData.length);

                            $('#xq_gridDXKS').datagrid({
                                data:xqAllKsData
                            });
                            break;
                    }
                }
            },
            error: function (xhr, status, error) {
                //XMLHttpRequest 對象、錯誤信息、(可選)捕獲的異常對象
                alert("err: " + error + " status:" + status);
            }
        });
    }


</script>

</body>
</html>
相關文章
相關標籤/搜索