瀏覽代碼

添加后台

刘桂岩 5 年之前
父節點
當前提交
9a39a566cb

+ 10 - 10
application/manage/controller/Counts.php

@@ -30,33 +30,33 @@ class Counts extends Base {
             switch($k){
                 case 'upload1':
                     if($params['upload1'] == null){
-                        continue;
+                        continue 2;
                     }
                     $where[] = ' s.createdAt > \''.$params['upload1'].'\' ';
                     break;
                 case 'upload2':
                     if($params['upload2'] == null){
-                        continue;
+                        continue 2;
                     }
                     $where[] = ' s.createdAt < \''.$params['upload2'].'\' ';
                     break;
                 case 'exam1':
                     if($params['exam1'] == null){
-                        continue;
+                        continue 2;
                     }
                     $exam1 = str_replace('-', '', $params['exam1']);
                     $where[] = ' s.studydate > \''.$exam1.'\' ';
                     break;
                 case 'exam2':
                     if($params['exam2'] == null){
-                        continue;
+                        continue 2;
                     }
                     $exam2 = str_replace('-', '', $params['exam2']);
                     $where[] = ' s.studydate < \''.$exam2.'\' ';
                     break;
                 case 'exam_class':
                     if($params['exam_class'] == null){
-                        continue;
+                        continue 2;
                     }
                     $where[] = 's.modality=\''.$params['exam_class'].'\' ';
                     break;
@@ -114,33 +114,33 @@ class Counts extends Base {
             switch($k){
                 case 'upload_datetime1':
                     if($params['upload_datetime1'] == null){
-                        continue;
+                        continue 2;
                     }
                     $where[] = ' s.createdAt > \''.$params['upload_datetime1'].'\' ';
                     break;
                 case 'upload_datetime2':
                     if($params['upload_datetime2'] == null){
-                        continue;
+                        continue 2;
                     }
                     $where[] = ' s.createdAt < \''.$params['upload_datetime2'].'\' ';
                     break;
                 case 'exam_datetime1':
                     if($params['exam_datetime1'] == null){
-                        continue;
+                        continue 2;
                     }
                     $exam1 = str_replace('-', '', $params['exam_datetime1']);
                     $where[] = ' s.studydate > \''.$exam1.'\' ';
                     break;
                 case 'exam_datetime2':
                     if($params['exam_datetime2'] == null){
-                        continue;
+                        continue 2;
                     }
                     $exam2 = str_replace('-', '', $params['exam_datetime2']);
                     $where[] = ' s.studydate < \''.$exam2.'\' ';
                     break;
                 case 'exam_class':
                     if($params['exam_class'] == null){
-                        continue;
+                        continue 2;
                     }
                     $where[] = 's.modality=\''.$params['exam_class'].'\' ';
                     break;

+ 26 - 1
application/manage/controller/Institution.php

@@ -88,7 +88,8 @@ class Institution extends Base {
                 $data["id"] = $parms['yid'];
             }
             $data["createdAt"] = date("Y-m-d H:i:s");
-            Db::table("institution")->insert($data);
+            $id = Db::table("institution")->insertGetId($data);
+            $this->saveContact($data["parent_institution"],$id);
             echo "insert_ok;" . $data["id"];
             SysLogs::log("institution", "C", json_encode($data));
         } else {
@@ -98,11 +99,35 @@ class Institution extends Base {
             $data["updatedAt"] = date("Y-m-d H:i:s");
             // 更新
             Db::table("institution")->where("id", $id)->update($data);
+            $this->saveContact($data["parent_institution"],$id);
             SysLogs::log("institution", "U", "id = " . $id . " --> " . json_encode($data));
             echo "update_ok";
         }
     }
 
+    public function saveContact($parent,$id)
+    {
+        if(empty($parent)){
+            return '';
+        }
+        $local_name = DB::table('institution')->where('id',$id)->value('name');
+        foreach ($parent as $k=>$v){
+            $data = DB::table('remote_contact')->where('hospital_id',$id)->where('super_hospital_id',$v)->find();
+            if(!empty($data)){
+                return '';
+            }
+            $parent_name = DB::table('institution')->where('id',$v)->value('name');
+            $info = [
+                'hospital_id'=>$id,
+                'super_hospital_id'=>$v,
+                'timestamp'=>time(),
+                'hospital_name'=>$local_name,
+                'super_hospital_name'=>$parent_name
+            ];
+            DB::table('remote_contact')->insert($info);
+        }
+    }
+    
     /**
      * 编辑窗口
      * @return type

+ 323 - 0
application/manage/controller/Remote.php

@@ -0,0 +1,323 @@
+<?php
+
+namespace app\manage\controller;
+
+use think\Controller;
+use think\Db;
+use think\Session;
+use think\Config;
+use think\Cookie;
+use think\Request;
+use app\common\library\SysLogs;
+use app\common\library\UUIDs;
+
+/*
+ * 
+ */
+
+class Remote extends Base {
+
+    public function remote() {
+        // 查询出全部的机构,显示上级机构使用
+        $rs = Db::table("institution")->select();
+        $this->assign("institutions", $rs);
+
+        $agents = Db::table("manager")->where("role_id", "2")->field("id,username as 'text'")->select();
+        $this->assign("agents", $agents);
+
+        return $this->fetch('remote');
+    }
+
+    public function local() {
+        // 查询出全部的机构,显示上级机构使用
+        $rs = Db::table("institution")->select();
+        $this->assign("institutions", $rs);
+
+        $agents = Db::table("manager")->where("role_id", "2")->field("id,username as 'text'")->select();
+        $this->assign("agents", $agents);
+
+        return $this->fetch('local');
+    }
+
+    /**
+     * 列表数据
+     */
+    public function localdatas() {
+        $request = Request::instance();
+        $params = $request->param();
+        /*$pid = isset($params["pid"]) ? $params["pid"] : null;
+        $status = isset($params["status"]) ? $params["status"] : null;
+        $name = isset($params["name"]) ? $params["name"] : null;
+        $whereArr = array();
+        if ($pid != null) {
+            $whereArr["parent_institution"] = array("like", "%" . $pid . "%");
+        }
+        if ($status != null) {
+            $whereArr["status"] = $status;
+        }
+        if ($name != null) {
+            $whereArr["name"] = array("like", "%" . $name . "%");
+        }*/
+        $manage = Session::get('session_manager');
+        $rs = Db::table("remote_cost")->where('hospital_id',$manage['institution_id'])->select();
+        echo json_encode($rs);
+    }
+
+    public function remotedatas() {
+        $request = Request::instance();
+        $params = $request->param();
+        /*$pid = isset($params["pid"]) ? $params["pid"] : null;
+        $status = isset($params["status"]) ? $params["status"] : null;
+        $name = isset($params["name"]) ? $params["name"] : null;
+        $whereArr = array();
+        if ($pid != null) {
+            $whereArr["parent_institution"] = array("like", "%" . $pid . "%");
+        }
+        if ($status != null) {
+            $whereArr["status"] = $status;
+        }
+        if ($name != null) {
+            $whereArr["name"] = array("like", "%" . $name . "%");
+        }*/
+        $manage = Session::get('session_manager');
+        $rs = Db::table("remote_cost")->where('super_hospital_id',$manage['institution_id'])->select();
+        echo json_encode($rs);
+    }
+
+    /**
+     * 更新或创建机构信息
+     */
+    public function save() {
+        $manage = Session::get('session_manager');
+        $request = Request::instance();
+        $parms = $request->param();
+        $id = $parms["id"];
+        $data = array();
+        $data["hospital_id"] = $parms["hospital_id"];
+        $data["super_hospital_id"] = $manage['institution_id'];
+        $data["exam_class"] = $parms["exam_class"];
+        $data["super_doctor_id"] = $parms["super_doctor_id"];
+        $data["remark"] = $parms["remark"];
+        $data["money"] = $parms["money"];
+        $data["timestamp"] = time();
+        $doctor = DB::table('doctors')->where('id',$parms['super_doctor_id'])->field('realname,username,is_admin')->find();
+        if(empty($doctor['realname'])){
+            $data['super_doctor_name'] = $doctor['username'];
+        }else{
+            $data['super_doctor_name'] = $doctor['realname'];
+        }
+        $data['is_admin'] = $doctor['is_admin'] ?? '';
+//        var_dump($data);die;
+        // ID有值,认为是更新
+        if (empty($id)) {
+            // 无值,认为是添加
+            $id = Db::table("remote_cost")->insertGetId($data);
+            echo "insert_ok;" . $id;
+            SysLogs::log("remote", "C", json_encode($data));
+        } else {
+            // 更新
+            Db::table("remote_cost")->where("id", $id)->update($data);
+            SysLogs::log("remote", "U", "id = " . $id . " --> " . json_encode($data));
+            echo "update_ok";
+        }
+    }
+
+    public function saveContact($parent,$id)
+    {
+        if(empty($parent)){
+            return '';
+        }
+        $local_name = DB::table('institution')->where('id',$id)->value('name');
+        foreach ($parent as $k=>$v){
+            $data = DB::table('remote_contact')->where('hospital_id',$id)->where('super_hospital_id',$v)->find();
+            if(!empty($data)){
+                return '';
+            }
+            $parent_name = DB::table('institution')->where('id',$v)->value('name');
+            $info = [
+                'id'=>UUIDs::uuid16(),
+                'hospital_id'=>$id,
+                'super_hospital_id'=>$v,
+                'timestamp'=>time(),
+                'hospital_name'=>$local_name,
+                'super_hospital_name'=>$parent_name
+            ];
+            DB::table('remote_contact')->insert($info);
+        }
+    }
+
+    /**
+     * 编辑窗口
+     * @return type
+     */
+    public function edit() {
+
+        // 显示下级机构使用
+        $manage = Session::get('session_manager');
+        // 显示下级机构
+        $insRs = Db::table("remote_contact")->where('super_hospital_id',$manage['institution_id'])->field("hospital_id as id,hospital_name as 'name'")->select();
+        $this->assign("insJson", $insRs);
+        $class = DB::table('constant')->where('parent_id','exam_class')->column('constant_value');
+        $this->assign("class", $class);
+        $doctors = DB::table('doctors')->where('institution_id',$manage['institution_id'])->field('id,realname,username')->select();
+        foreach ($doctors as $k=>$v){
+            if(empty($v['realname'])){
+                $doctors[$k]['realname'] = $v['username'];
+            }
+        }
+        $this->assign("doctors", $doctors);
+        if (isset($_GET["id"])) {
+            $id = $_GET["id"];
+            if ($id != null) {
+                $remote = Db::table("remote_cost")->where("id", $id)->find();
+                $this->assign("remote", $remote);
+                if (count($remote) > 0) {
+                    $this->assign("remote", $remote);
+                }
+            }
+        }
+        return $this->fetch('edit');
+    }
+
+    /**
+     * 删除记录
+     */
+    public function delete() {
+        if (isset($_GET["ids"])) {
+            $ids = $_GET["ids"];
+            if (!empty($ids)) {
+                $idArr = explode(",", $ids);
+                if (count($idArr) > 0) {
+                    Db::table("remote_cost")->where("id", "in", $idArr)->delete();
+                }
+                SysLogs::log("remote_cost", "D", $ids);
+                echo "delete_ok";
+                return;
+            }
+        }
+        echo "fail";
+    }
+
+    /**
+     * 代理商树
+     */
+    public function agents() {
+        $treeData = array();
+        $rows = Db::table("manager")->where("role_id", "2")->field("id,username as 'text'")->select();
+        $parentTree = array();
+        $parentTree["id"] = "";
+        $parentTree["text"] = "请选择";
+        array_push($treeData, $parentTree);
+        if (!empty($rows)) {
+            foreach ($rows as $key => $val) {
+                array_push($treeData, $val);
+            }
+        }
+        echo json_encode($treeData);
+    }
+
+    public function deptview() {
+        $request = Request::instance();
+        $params = $request->param();
+        if (isset($params["insId"])) {
+            $this->assign("insId", $params["insId"]);
+        } else {
+            echo "parameter insId error!";
+            return;
+        }
+        return $this->fetch('dept');
+    }
+
+    /**
+     * 获取医院科室数据
+     * @return type
+     */
+    public function deptdatas() {
+        $request = Request::instance();
+        $params = $request->param();
+        if (!isset($params["insId"])) {
+            echo "please change a institution!";
+            return;
+        }
+        $ins = Db::table("institution")->where("id", $params["insId"])->find();
+        if (empty($ins)) {
+            echo "please change a institution(2)!";
+            return;
+        }
+        $whereArr = array();
+        $whereArr["institution_id"] = $params["insId"];
+        $rootMenuData = array();
+        // 准备根节点
+        $rootMenuData["id"] = "root";
+        $rootMenuData["pId"] = "0";
+        $rootMenuData["name"] = "科室管理(" . $ins["name"] . ")";
+        $rootMenuData["url"] = "";
+        $rootMenuData["open"] = "true";
+
+        // 查询全部数据
+        $menuData = $info = DB::table('department')->where($whereArr)->select();
+        $jsonarray = array();
+        if ($menuData != null) {
+            foreach ($menuData as $k => $val) {
+                $data = array();
+                $data["id"] = $val["id"];
+                $data['pId'] = $val["parent_id"];
+                $data['name'] = $val["department_name"];
+                $data['institutionid'] = $val["institution_id"];
+                $data['isreport'] = $val["is_report"];
+                $data['ordernum'] = $val["order_num"];
+                array_push($jsonarray, $data);
+            }
+        }
+        // 将根节点添加到树
+        array_unshift($jsonarray, $rootMenuData);
+        // 返回JSON数据
+        echo json_encode($jsonarray);
+    }
+
+    /**
+     * 添加或修改
+     */
+    public function deptupd() {
+        $id = $_GET["id"];
+        // id=&pid=root&name=%E5%A4%96%E7%A7%91&institutionid=&=0&ordernum=11
+        // ID有值,认为是更新
+        if (empty($id)) {
+            $data = array();
+            // 无值,认为是添加
+            $data["id"] = UUIDs::uuid16();
+            $data["parent_id"] = $_GET["pid"];
+            $data["department_name"] = $_GET["name"];
+            $data["institution_id"] = $_GET["institutionid"];
+            $data["order_num"] = $_GET["ordernum"];
+            $data["is_report"] = $_GET["isreport"];
+            Db::table("department")->insert($data);
+            echo "insert_ok";
+            SysLogs::log("constant", "C", json_encode($data));
+        } else {
+            // 更新
+            $data["id"] = $_GET["id"];
+            $data["parent_id"] = $_GET["pid"];
+            $data["department_name"] = $_GET["name"];
+            $data["institution_id"] = $_GET["institutionid"];
+            $data["order_num"] = $_GET["ordernum"];
+            $data["is_report"] = $_GET["isreport"];
+            Db::table("department")->where("id", $id)->update(["parent_id" => $data["parent_id"], "department_name" => $data["department_name"], "institution_id" => $data["institution_id"], "is_report" => $data["is_report"], "order_num" => $data["order_num"]]);
+            echo "update_ok";
+            SysLogs::log("constant", "U", $id . " --> " . json_encode($data));
+        }
+    }
+
+    public function deptdel() {
+        $id = $_GET["id"];
+        $result = Db::table("department")->delete($id);
+        if ($result) {
+            echo "delete_ok";
+            SysLogs::log("department", "D", $id . " --> delete_ok");
+        } else {
+            echo "delete_fail";
+            SysLogs::log("department", "D", $id . " --> delete_fail");
+        }
+    }
+
+}

+ 253 - 0
application/manage/view/remote/dept.html

@@ -0,0 +1,253 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>TODO supply a title</title>
+        {include file="../application/manage/view/commons/headers.html" }
+        <link href="/static/js/ztree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css" />
+        <script src="/static/js/ztree/js/jquery.ztree.all.min.js" type="text/javascript" ></script>
+        <style type="text/css">
+	.ztree li span.button.add {margin-left:2px; margin-right: -1px; background-position:-144px 0; vertical-align:top; *vertical-align:middle}
+	</style>
+        
+        <script type="text/javascript">
+		var curMenu = null, zTree_Menu = null;
+		var setting = {
+			view: {
+				addHoverDom: addHoverDom,removeHoverDom: removeHoverDom,
+				showLine: true, selectedMulti: false, dblClickExpand: false
+			},
+			data: { simpleData: { enable: true } },
+			callback: {
+				onNodeCreated: onNodeCreated,
+				beforeClick: beforeClick,
+				beforeEditName: beforeEditName,
+				beforeRemove:beforeRemove
+			},
+			edit: {
+				enable: true,
+				editNameSelectAll: true,
+				showRemoveBtn: true,
+				showRenameBtn: true
+			},
+			async: {
+				enable: true,
+				url:"/manage/institution/deptdatas?insId={$insId}",
+				autoParam:["id", "pId=pid", "name=n", "level=lv"],
+				otherParam:{"otherParam":"zTreeAsyncTest"},
+				dataFilter: filter
+			}
+		};
+		
+		function filter(treeId, parentNode, childNodes) {
+			if (!childNodes) return null;
+			for (var i=0, l=childNodes.length; i<l; i++) {
+				childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
+			}
+			return childNodes;
+		};
+		
+		function beforeRemove(treeId, treeNode){
+			if(confirm("确定删除节点("+treeNode.name+")?")){
+				$.ajax({
+					url:"/manage/institution/deptdel",
+					data:"id="+treeNode.id+"&t="+new Date(),
+					success:function(rs){
+						if(rs=="delete_ok"){
+							document.location.reload();
+						}else{
+							alert("操作失败!");
+						}
+					}
+				});
+			}
+			return false;
+		}
+		
+		function onNodeCreated(){
+			zTree_Menu = $.fn.zTree.getZTreeObj("menutree");
+			curMenu = zTree_Menu.getNodes()[0].children[0].children[0];
+			zTree_Menu.selectNode(curMenu);
+			var a = $("#" + zTree_Menu.getNodes()[0].tId + "_a");
+			a.addClass("cur");
+		}
+		
+		function beforeEditName(treeId, treeNode) {
+			var zTree = $.fn.zTree.getZTreeObj("menutree");
+			zTree.selectNode(treeNode);
+			$("#myform").find("input[name='id']").val(treeNode.id);
+			$("#myform").find("input[name='pid']").val(treeNode.pId);
+			$("#myform").find("input[name='name']").val(treeNode.name);
+                        $("#myform").find("input[name='isreport']").val(treeNode.isreport);
+			$("#myform").find("input[name='ordernum']").val(treeNode.ordernum);
+			editWin.window("open");
+			return false;
+		}
+		
+		var newCount = 1;
+		function addHoverDom(treeId, treeNode) {
+			var sObj = $("#" + treeNode.tId + "_span");
+			if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0) return;
+			var addStr = "<span class='button add' id='addBtn_" + treeNode.tId
+				+ "' title='add node' onfocus='this.blur();'></span>";
+			sObj.after(addStr);
+			var btn = $("#addBtn_"+treeNode.tId);
+			if (btn) btn.bind("click", function(){
+				//var zTree = $.fn.zTree.getZTreeObj("menutree");
+				//zTree.addNodes(treeNode, {id:(100 + newCount), pId:treeNode.id, name:"new node" + (newCount++)});
+				showAddChildMenuView(treeNode.id);
+				return false;
+			});
+		};
+		
+		// 显示添加窗口
+		function showAddChildMenuView(pid){
+			editWin.window("open");
+			$("#myform").find("input[name='pid']").val(pid);
+			$("#myform").find("input[name='id']").val("");
+			$("#myform").find("input[name='name']").val("");
+                        $("#myform").find("input[name='isreport']").val(0);
+			$("#myform").find("input[name='ordernum']").val("");
+		}
+		// 保存菜单
+		function save(){
+			var data=$("#myform").serialize();
+			$.ajax({
+				url:"/manage/institution/deptupd",
+				contentType: "application/x-www-form-urlencoded; charset=utf-8",
+				data:data+"&t="+new Date(),
+				success:function(rs){
+					if(rs=="insert_ok"){
+						document.location.reload();
+					}else if(rs=="update_ok"){
+						document.location.reload();
+					}else{
+						alert("操作失败!");
+					}
+				},error:function(e,e1,e2){
+                                    alert(e2);
+                                }
+			});
+		}
+		
+		function removeHoverDom(treeId, treeNode) {
+			$("#addBtn_"+treeNode.tId).unbind().remove();
+		};
+
+		function beforeClick(treeId, node) {
+			if (node.isParent) {
+				if (node.level === 0) {
+					var pNode = curMenu;
+					while (pNode && pNode.level !==0) {
+						pNode = pNode.getParentNode();
+					}
+					if (pNode !== node) {
+						var a = $("#" + pNode.tId + "_a");
+						a.removeClass("cur");
+						zTree_Menu.expandNode(pNode, false);
+					}
+					a = $("#" + node.tId + "_a");
+					a.addClass("cur");
+
+					var isOpen = false;
+					for (var i=0,l=node.children.length; i<l; i++) {
+						if(node.children[i].open) {
+							isOpen = true;
+							break;
+						}
+					}
+					if (isOpen) {
+						zTree_Menu.expandNode(node, true);
+						curMenu = node;
+					} else {
+						zTree_Menu.expandNode(node.children[0].isParent?node.children[0]:node, true);
+						curMenu = node.children[0];
+					}
+				} else {
+					zTree_Menu.expandNode(node);
+				}
+			}
+			return !node.isParent;
+		}
+		
+		// 菜单编辑框
+		var editWin;
+		function initEditWin(){
+			editWin=$("#editWin").dialog({
+	            modal: true,
+	            title: "菜单信息编辑",
+	            closed: true,
+	            iconCls: 'icon-edit',
+	            width:500, height:350,
+	            left:"25%",top:50,
+	            modal: true, cache: false,resizable:true,draggable:true,
+	            collapsible:false
+	        });
+			editWin.window("close");
+		}
+
+		$(document).ready(function(){
+			$.fn.zTree.init($("#menutree"), setting);
+			initEditWin();
+		});
+		
+		function showWin(){
+			editWin.window("open");
+		}
+		
+	</script>
+        
+    </head>
+    <body>
+        <div id="menu" data-options="region:'west',iconCls:'icon-forward',split:true,border:false" title="功能导航" style="height:100%;width: 100%; overflow: auto;" >
+            <ul id="menutree" class="ztree" style="height:100%;width: 100%;padding: 0px; margin: 0px;"></ul>
+        </div>
+
+        <div id="editWin" buttons="#dlg-buttons" auth_id="AUTH_001" auth_name="编码框" >
+            <form id="myform" action="" method="post" >
+                <input name="id" type="hidden" /><input name="institutionid" type="hidden" value="{$insId}" size="35" />
+                <table id="editGrid" fitColumns="false" style="fitColumns:false" >
+                    <thead>
+                        <tr>
+                            <th height="32" width="22%" data-options="field:'code'" align="right" >名称&nbsp;</th>
+                            <th width="80%" data-options="field:'name'">值</th>
+                        </tr>
+                    </thead>
+                    <tbody>
+                        <tr>
+                            <td height="32" align="right" >上级科室:</td>
+                            <td><input name="pid" type="text" size="35" /></td>
+                        </tr>
+                        <tr>
+                            <td height="32" align="right"  >科室名称:</td>
+                            <td><input name="name" type="text" size="35" /></td>
+                        </tr>
+                        <tr>
+                            <td height="32" align="right" >报告权限:</td>
+                            <td>
+                                <input name="isreport" id="isreport_1" type="radio" value="1" /><label for="isreport_1" >有权限</label>
+                                <input name="isreport" id="isreport_2" type="radio" value="0" checked="checked" /><label for="isreport_2" >无权限</label>
+                            </td>
+                        </tr>
+                        <tr>
+                            <td height="32" align="right" >排序号码:</td>
+                            <td><input name="ordernum" type="text" size="15" /></td>
+                        </tr>
+                    </tbody>
+                </table>
+
+            </form>
+            <div id="dlg-buttons">
+                <table cellpadding="0" cellspacing="0" style="width:100%">
+                    <tr>
+                        <td>
+                            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" onclick="save()" >保存</a>
+                            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true" onclick="editWin.window('close')" >关闭</a>
+                        </td>
+                    </tr>
+                </table>
+            </div>
+        </div>
+
+
+    </body>
+</html>

+ 124 - 0
application/manage/view/remote/edit.html

@@ -0,0 +1,124 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>TODO supply a title</title>
+        {include file="../application/manage/view/commons/headers.html" }
+        
+        <script >
+
+            
+            // 保存信息
+            function save(){
+                var data=$("#myform").serialize();
+                $.ajax({
+                        url:"/manage/remote/save",
+                        data:data,type:"get",
+                        success:function(rs){
+                            if(rs.indexOf("insert_ok")>=0){
+                                    document.location.href="edit?id="+rs.split(";")[1];
+                            }else if(rs=="update_ok"){
+                                    document.location.reload();
+                            }else{
+                                    alert("保存失败!");
+                            }
+                        },error:function(e,e1,e2){
+                            alert(e2);
+                        }
+                });
+            }
+            
+            
+        </script>
+        
+        
+    </head>
+    <body>        
+        <form id="myform" action="" method="get" >
+            <input name="id" type="hidden" value="{if  isset($remote) }{$remote.id}{/if}" />
+        <table class="editform" width="99%" border="0" style="margin: 5px auto;" cellpadding="1" cellspacing="1" >
+            <tr>
+                    <th width="105" height="38" align="right" >属性&nbsp;</th>
+                    <th>信息</th>
+            </tr>
+            <tr>
+                    <th height="32" align="right" >下级机构:</th>
+                    <td>
+                        <select name="hospital_id">
+                            {if !isset($remote)}<option value = '' selected>请选择下级机构</option>{/if}
+                            {foreach insJson as $key => $val}
+                            <option  {if isset($remote) && $val.id==$remote.hospital_id }selected{/if}  value ={$val.id} >{$val.name}</option>
+                            {/foreach}
+                        </select>
+                    </td>
+                    <th height="32" align="right" >检查类型:</th>
+                    <td >
+                        <select name="exam_class">
+                            {if !isset($remote)}<option value = '' selected>请选择检查类型</option>{/if}
+                            {foreach $class as $key => $val}
+                            <option  {if isset($remote) && $val==$remote.exam_class }selected{/if}  value ={$val}>{$val}</option>
+                            {/foreach}
+                        </select>
+                    </td>
+            </tr>
+            <tr>
+                    <th height="32" align="right" >远程医生:</th>
+                    <td >
+                        <select name="super_doctor_id">
+                            {if !isset($remote)}<option value = '' selected><option value = '' selected>请选择远程医生</option>{/if}
+                            {foreach $doctors as $key => $val}
+                            <option  {if isset($remote) && $val.id==$remote.super_doctor_id }selected{/if}  value ={$val.id}>{$val.realname}</option>
+                            {/foreach}
+                        </select>
+                    </td>
+                    <th height="32" align="right" >问诊价格:</th>
+                    <td >
+                    <input name="money" class="easyui-textbox" type="text" size="25" value="{if  isset($remote) }{$remote.money}{/if}" />
+                    </td>
+                    
+            </tr>
+            <tr>
+                    <th height="32" align="right" >备注:</th>
+                    <td colspan="3" >
+                    <textarea name="remark" cols="55" class="easyui-textbox" rows="3" >{if  isset($remote) }{$remote.remark}{/if}</textarea>
+                    </td>
+            </tr>
+            {if isset($remote) }
+            <tr>
+                    <th height="32" align="right" >{if $remote["createdAt"] != null }创建时间:{/if}</th>
+                    <td >{if $remote["createdAt"] != null }
+                    <input type="text" readonly="readonly" class="easyui-datetimebox" size="20" value="{$remote['createdAt']}" />{/if}
+                    </td>            
+                    <th height="32" align="right" >{if $remote["updatedAt"] != null }更新时间:{/if}</th>
+                    <td >{if $remote["updatedAt"] != null }
+                    <input type="text" readonly="readonly" class="easyui-datetimebox" size="20" value="{$remote['updatedAt']}" />{/if}
+                    </td>
+            </tr>
+            {/if}
+            <tr>
+                    <th height="32" >&nbsp;</th>
+                    <td>
+                    <a type="button" class="easyui-linkbutton" data-options="iconCls:'icon-save'" icon="icon-save" onclick="save()" >保存</a>
+                    <a type="button" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="window.parent.closeEditWin('reload');" >关闭</a>
+                    </td>
+            </tr>
+            <tr >
+                    <th height="32" >&nbsp;</th>
+                    <td>
+                    &nbsp;
+                    </td>
+            </tr>
+        </table>
+        </form>
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+    </body>
+</html>

+ 238 - 0
application/manage/view/remote/local.html

@@ -0,0 +1,238 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>TODO supply a title</title>
+        {include file="../application/manage/view/commons/headers.html" }
+        
+        <script >
+
+            var institutionsData=new Array();
+            {if isset($institutions) }
+            {foreach $institutions as $k=>$value }
+            institutionsData.push({"name":"{$value['name']}","id":"{$value['id']}" });
+            {/foreach}
+            {else}
+            var institutionsData=[];
+            {/if}
+
+            var agentArray=new Array();
+            {if isset($agents) }
+            {foreach $agents as $k=>$value }
+            agentArray.push({"name":"{$value['text']}","id":"{$value['id']}" });
+            {/foreach}
+            {/if}
+            
+            // 编辑窗口
+            var $editWin;
+            var $deptEditWin;
+            $(function(){
+                    $editWin = $('#edit-window').window({
+                        title: '关键词编辑',
+                        width: 820,height: 500,
+                        top: ($(window).height() -500 ) /2 ,
+                        left: ($(window).width() -820 ) /2 ,
+                        shadow: true,modal: true,
+                        iconCls: 'icon-edit',closed: true,
+                        minimizable: false,maximizable: false,collapsible: false
+                    });
+                    $deptEditWin = $('#dept-edit-window').window({
+                        title: '关键词编辑',
+                        width: 820,height: 500,
+                        top: ($(window).height() -500 ) /2 ,
+                        left: ($(window).width() -820 ) /2 ,
+                        shadow: true,modal: true,
+                        iconCls: 'icon-edit',closed: true,
+                        minimizable: false,maximizable: false,collapsible: false
+                    });
+            });
+            
+            function dateFormatter(date){
+	    	if(typeof date=="undefined"){ return "--"; }
+	    	return new Date(date).format("yyyyMMdd hh:mm:ss");
+	    }
+            
+            function chargingModeFormatter(mode){
+	    	if(typeof mode=="undefined"){ return "--"; }
+	    	if(mode=="1"){ return "向患者收费";
+                }else if(mode=="2"){ return "向医院收费";
+                }else{ return "--";
+                }
+	    }
+            
+            function insFormatter(ids,row){
+                if(ids!=null){
+                    var idsArr=ids.split(",");
+                    var names="";
+                    for( var i=0;i<idsArr.length;i++ ){
+                        var id=idsArr[i];
+                        for(var n=0;n<institutionsData.length;n++){
+                            var row=institutionsData[n];
+                            if(row.id==id){
+                                names = names + row.name +",";
+                            }
+                        }
+                    }
+                    return names;
+                }
+	    	return "<font color='#ccc' >顶级机构<font>";
+            }
+            
+            function agentFormatter(id,rows){
+                for(var n=0;n<agentArray.length;n++){
+                    var row=agentArray[n];
+                    if(row.id==id){
+                        return row.name;
+                    }
+                }
+	    	return "--";
+            }
+            
+            function statusFormatter(status){
+                if(status=="1"){
+                    return "可用";
+                }else if(status=="2"){
+                    return "不可用";
+                }else{
+                    return status;
+                }
+            }
+
+                function moneyFormatter($money){
+                    $m = $money/100;
+                    return $m;
+                }
+                function adminFormatter($admin){
+                    if($admin=="1"){
+                        return "是";
+                    }else {
+                        return "否";
+                    }
+                }
+            
+            function commandsFormatter(id,row){
+	    	var cmdEdit="<a href='#' onclick=\"javascript:showEditWin('"+row.id+"');\" >编辑</a>";
+                cmdEdit+="&nbsp;<a href='#' onclick=\"javascript:deleteRow('"+row.id+"');\" >删除</a>";
+	    	return cmdEdit;
+	    }
+            
+            $(function(){
+                
+                var height=$(document).height();
+                $("#dg").height(height);
+                $('#dg').datagrid({
+                    url:'/manage/remote/localdatas',
+                    idField:'id',method: 'get',rownumbers: true,showFooter: true,striped:true,singleSelect:true,selectOnCheck:false,
+                    toolbar: '#tb', fitColumns : true,pageList: [dgRowSize,dgRowSize*2,100],pagination:true,pageSize:dgRowSize,
+                   // title:"机构信息管理",
+                    columns:[[
+                            {field:'id',title:'ID',width:180 ,hidden:true },
+                            {field:'hospital_id',title:'下级机构',formatter:insFormatter  },
+                            {field:'super_hospital_id',title:'上级机构',align:'left',formatter:insFormatter },
+                            {field:'exam_class',title:'检查类型',width:80},
+                            {field:'super_doctor_name',title:'远程医生',width:100  },
+                            {field:'money',title:'问诊价格',width:120 ,formatter:moneyFormatter },
+                            {field:'is_admin',title:'是否为医生管理员',width:120 ,formatter:adminFormatter  },
+                            {field:'createdAt',title:'创建时间',align: 'center', width:135, formatter:dateFormatter },
+                            {field:'updatedAt',title:'更新时间',align: 'center', width:135, formatter:dateFormatter },
+                    ]],
+                    onDblClickRow :function(index,rowData){
+                        showEditWin(rowData.id);
+                    },
+                });
+
+                $("#submit").click(function(){
+                    reload();
+                });
+                
+            });
+            
+            function reload(){
+                var institution_id=$("#institution_id").combotree("getValue");
+                var status=$("#status").combobox("getValue");
+                var name=$("#name").textbox("getValue");
+                var queryParams = $('#dg').datagrid('options').queryParams;
+                queryParams.pid=institution_id;
+                queryParams.status=status;
+                queryParams.name=name;
+                $('#dg').datagrid('options').queryParams=queryParams;
+                $('#dg').datagrid("reload");
+            }
+            
+            // 显示编辑窗口
+            function showEditWin(id){
+                if("undefined"== typeof id){
+                    $editWin.window('open');$('#editFrame').attr('src','/manage/remote/edit');
+                }else{
+                    $editWin.window('open');$('#editFrame').attr('src','/manage/remote/edit?id='+id);
+                }
+            }
+            
+            function showDeptEditWin(id){
+                if("undefined"== typeof id){
+                    alert("请选择医院编辑科室!");
+                }else{
+                    $deptEditWin.window('open');$('#deptEditFrame').attr('src','/manage/institution/deptview?insId='+id);
+                }
+            }
+            
+            function deleteRow(id){
+                $.messager.confirm('Confirm','确定要删除这条记录吗?',function(r){
+                    if(r){
+                        $.ajax({
+                            url:"/manage/remote/delete",
+                            data:"ids="+id+"&t="+new Date(),
+                            success:function(rs){
+                                if(rs=="delete_ok"){
+                                    alert("操作已成功!");
+                                    document.location.reload();
+                                }else{
+                                    alert("操作失败!");
+                                }
+                            }
+                        });
+                    }
+                });
+            }
+            
+            // 关闭编辑窗口
+            function closeEditWin(isReload){
+                    $editWin.window('close');
+                    if(isReload=="reload"){
+                            document.location.reload();
+                    }
+            }
+            
+            $(function(){
+                $('#institution_id').combotree({
+                    required:true,multiple:false,editable:false,
+                    valueField:'id',textField:'name',panelWidth:350,
+                    url:"/manage/institution/insCombobox"
+                });
+                $("#reset").click(function(){
+                    $('#institution_id').combotree("setValue","");
+                    $('#status').combobox("setValue","");
+                    $('#username').textbox("setValue","");
+                    $("#name").textbox("setValue","");
+                });
+            });
+            
+            
+        </script>
+    </head>
+    <body>
+        <table id="dg" class="easyui-datagrid" style="width:100%;height:auto;" ></table>
+        <div id="tb" class="editform" style="display: none; padding-top: 1px;">&nbsp;
+<!--            父机构:<input type="text" name="institution_id" id="institution_id" />&nbsp;-->
+<!--            状态:<select id="status" name="status" class="easyui-combobox" style="width: 100px; " >-->
+<!--            <option value="" >查询全部</option><option value="1" >可用</option><option value="2" >不可用</option>-->
+<!--            </select>&nbsp;-->
+<!--            名称:<input type="text" id="name" name="name" class="easyui-textbox" style="width: 200px; vertical-align: middle;" />&nbsp;-->
+<!--            <a id="submit" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width: 80px">查询</a>-->
+<!--            <a id="reset" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-clear'" style="width: 80px" >重置</a>-->
+<!--            &nbsp;&nbsp;&nbsp;&nbsp;-->
+<!--            <a id="add" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="javascript:showEditWin()" style="width: 80px">添加</a>-->
+        </div>
+        <div id="edit-window" class="easyui-window" style="width: 80%;height: 450px;" ><iframe src="about:blank" id="editFrame" width="100%" height="100%" frameborder="0" scrolling="no" ></iframe></div>
+        <div id="dept-edit-window" class="easyui-window" style="width: 80%;height: 450px;" ><iframe src="about:blank" id="deptEditFrame" width="100%" height="100%" frameborder="0" scrolling="no" ></iframe></div>
+    </body>
+</html>

+ 239 - 0
application/manage/view/remote/remote.html

@@ -0,0 +1,239 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>TODO supply a title</title>
+        {include file="../application/manage/view/commons/headers.html" }
+        
+        <script >
+
+            var institutionsData=new Array();
+            {if isset($institutions) }
+            {foreach $institutions as $k=>$value }
+            institutionsData.push({"name":"{$value['name']}","id":"{$value['id']}" });
+            {/foreach}
+            {else}
+            var institutionsData=[];
+            {/if}
+
+            var agentArray=new Array();
+            {if isset($agents) }
+            {foreach $agents as $k=>$value }
+            agentArray.push({"name":"{$value['text']}","id":"{$value['id']}" });
+            {/foreach}
+            {/if}
+            
+            // 编辑窗口
+            var $editWin;
+            var $deptEditWin;
+            $(function(){
+                    $editWin = $('#edit-window').window({
+                        title: '关键词编辑',
+                        width: 820,height: 500,
+                        top: ($(window).height() -500 ) /2 ,
+                        left: ($(window).width() -820 ) /2 ,
+                        shadow: true,modal: true,
+                        iconCls: 'icon-edit',closed: true,
+                        minimizable: false,maximizable: false,collapsible: false
+                    });
+                    $deptEditWin = $('#dept-edit-window').window({
+                        title: '关键词编辑',
+                        width: 820,height: 500,
+                        top: ($(window).height() -500 ) /2 ,
+                        left: ($(window).width() -820 ) /2 ,
+                        shadow: true,modal: true,
+                        iconCls: 'icon-edit',closed: true,
+                        minimizable: false,maximizable: false,collapsible: false
+                    });
+            })
+            
+            function dateFormatter(date){
+	    	if(typeof date=="undefined"){ return "--"; }
+	    	return new Date(date).format("yyyyMMdd hh:mm:ss");
+	    }
+            
+            function chargingModeFormatter(mode){
+	    	if(typeof mode=="undefined"){ return "--"; }
+	    	if(mode=="1"){ return "向患者收费";
+                }else if(mode=="2"){ return "向医院收费";
+                }else{ return "--";
+                }
+	    }
+            
+            function insFormatter(ids,row){
+                if(ids!=null){
+                    var idsArr=ids.split(",");
+                    var names="";
+                    for( var i=0;i<idsArr.length;i++ ){
+                        var id=idsArr[i];
+                        for(var n=0;n<institutionsData.length;n++){
+                            var row=institutionsData[n];
+                            if(row.id==id){
+                                names = names + row.name +",";
+                            }
+                        }
+                    }
+                    return names;
+                }
+	    	return "<font color='#ccc' >顶级机构<font>";
+            }
+            
+            function agentFormatter(id,rows){
+                for(var n=0;n<agentArray.length;n++){
+                    var row=agentArray[n];
+                    if(row.id==id){
+                        return row.name;
+                    }
+                }
+	    	return "--";
+            }
+            
+            function statusFormatter(status){
+                if(status=="1"){
+                    return "可用";
+                }else if(status=="2"){
+                    return "不可用";
+                }else{
+                    return status;
+                }
+            }
+
+                function moneyFormatter($money){
+                    $m = $money/100;
+                    return $m;
+                }
+                function adminFormatter($admin){
+                    if($admin=="1"){
+                        return "是";
+                    }else {
+                        return "否";
+                    }
+                }
+
+            function commandsFormatter(id,row){
+	    	var cmdEdit="<a href='#' onclick=\"javascript:showEditWin('"+row.id+"');\" >编辑</a>";
+                cmdEdit+="&nbsp;<a href='#' onclick=\"javascript:deleteRow('"+row.id+"');\" >删除</a>";
+	    	return cmdEdit;
+	    }
+            
+            $(function(){
+                
+                var height=$(document).height();
+                $("#dg").height(height);
+                $('#dg').datagrid({
+                    url:'/manage/remote/remotedatas',
+                    idField:'id',method: 'get',rownumbers: true,showFooter: true,striped:true,singleSelect:true,selectOnCheck:false,
+                    toolbar: '#tb', fitColumns : true,pageList: [dgRowSize,dgRowSize*2,100],pagination:true,pageSize:dgRowSize,
+                   // title:"机构信息管理",
+                    columns:[[
+                            {field:'id',title:'ID',width:180 ,hidden:true },
+                            {field:'hospital_id',title:'下级机构',formatter:insFormatter  },
+                            {field:'super_hospital_id',title:'上级机构',align:'left',formatter:insFormatter },
+                            {field:'exam_class',title:'检查类型',width:80},
+                            {field:'super_doctor_name',title:'远程医生',width:100  },
+                            {field:'money',title:'问诊价格',width:120 ,formatter:moneyFormatter },
+                            {field:'is_admin',title:'是否为医生管理员',width:120 ,formatter:adminFormatter  },
+                            {field:'createdAt',title:'创建时间',align: 'center', width:135, formatter:dateFormatter },
+                            {field:'updatedAt',title:'更新时间',align: 'center', width:135, formatter:dateFormatter },
+                            {field:'grid_commands',title:'操作',align: 'center',width:100, formatter:commandsFormatter },
+                    ]],
+                    onDblClickRow :function(index,rowData){
+                        showEditWin(rowData.id);
+                    },
+                });
+
+                $("#submit").click(function(){
+                    reload();
+                });
+                
+            });
+            
+            function reload(){
+                var institution_id=$("#institution_id").combotree("getValue");
+                var status=$("#status").combobox("getValue");
+                var name=$("#name").textbox("getValue");
+                var queryParams = $('#dg').datagrid('options').queryParams;
+                queryParams.pid=institution_id;
+                queryParams.status=status;
+                queryParams.name=name;
+                $('#dg').datagrid('options').queryParams=queryParams;
+                $('#dg').datagrid("reload");
+            }
+            
+            // 显示编辑窗口
+            function showEditWin(id){
+                if("undefined"== typeof id){
+                    $editWin.window('open');$('#editFrame').attr('src','/manage/remote/edit');
+                }else{
+                    $editWin.window('open');$('#editFrame').attr('src','/manage/remote/edit?id='+id);
+                }
+            }
+            
+            function showDeptEditWin(id){
+                if("undefined"== typeof id){
+                    alert("请选择医院编辑科室!");
+                }else{
+                    $deptEditWin.window('open');$('#deptEditFrame').attr('src','/manage/institution/deptview?insId='+id);
+                }
+            }
+            
+            function deleteRow(id){
+                $.messager.confirm('Confirm','确定要删除这条记录吗?',function(r){
+                    if(r){
+                        $.ajax({
+                            url:"/manage/remote/delete",
+                            data:"ids="+id+"&t="+new Date(),
+                            success:function(rs){
+                                if(rs=="delete_ok"){
+                                    alert("操作已成功!");
+                                    document.location.reload();
+                                }else{
+                                    alert("操作失败!");
+                                }
+                            }
+                        });
+                    }
+                });
+            }
+            
+            // 关闭编辑窗口
+            function closeEditWin(isReload){
+                    $editWin.window('close');
+                    if(isReload=="reload"){
+                            document.location.reload();
+                    }
+            }
+            
+            $(function(){
+                $('#institution_id').combotree({
+                    required:true,multiple:false,editable:false,
+                    valueField:'id',textField:'name',panelWidth:350,
+                    url:"/manage/institution/insCombobox"
+                });
+                $("#reset").click(function(){
+                    $('#institution_id').combotree("setValue","");
+                    $('#status').combobox("setValue","");
+                    $('#username').textbox("setValue","");
+                    $("#name").textbox("setValue","");
+                });
+            });
+            
+            
+        </script>
+    </head>
+    <body>
+        <table id="dg" class="easyui-datagrid" style="width:100%;height:auto;" ></table>
+        <div id="tb" class="editform" style="display: none; padding-top: 1px;">&nbsp;
+<!--            父机构:<input type="text" name="institution_id" id="institution_id" />&nbsp;-->
+<!--            状态:<select id="status" name="status" class="easyui-combobox" style="width: 100px; " >-->
+<!--            <option value="" >查询全部</option><option value="1" >可用</option><option value="2" >不可用</option>-->
+<!--            </select>&nbsp;-->
+<!--            名称:<input type="text" id="name" name="name" class="easyui-textbox" style="width: 200px; vertical-align: middle;" />&nbsp;-->
+<!--            <a id="submit" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width: 80px">查询</a>-->
+<!--            <a id="reset" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-clear'" style="width: 80px" >重置</a>-->
+            &nbsp;&nbsp;&nbsp;&nbsp;
+            <a id="add" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="javascript:showEditWin()" style="width: 80px">添加</a>
+        </div>
+        <div id="edit-window" class="easyui-window" style="width: 80%;height: 450px;" ><iframe src="about:blank" id="editFrame" width="100%" height="100%" frameborder="0" scrolling="no" ></iframe></div>
+        <div id="dept-edit-window" class="easyui-window" style="width: 80%;height: 450px;" ><iframe src="about:blank" id="deptEditFrame" width="100%" height="100%" frameborder="0" scrolling="no" ></iframe></div>
+    </body>
+</html>