|
@@ -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");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|