소스 검색

医院。增删改查

sugangqiang 2 년 전
부모
커밋
b6f9c25569

+ 151 - 173
app/admin/controller/nhc/Hospital.php

@@ -13,215 +13,193 @@ use think\facade\Db;
 class Hospital extends AdminController {
 
     public function index() {
-        return view("");
+        $where = [];
+        $where[] = ["status", "<>", 3];
+        $medicalCommunities = Db::table("nhc_medical_community")->where($where)->order("num asc")->select()->toArray();
+        return view("", ["medicalCommunities" => $medicalCommunities]);
     }
 
     public function list() {
         $order = trim($this->request->param("order")) ?: "desc";
-        $offset = trim($this->request->param("offset")) ?: 0;
-        $limit = trim($this->request->param("limit")) ?: 10;
-        $type = trim($this->request->param("type"));
+        //$offset = trim($this->request->param("offset")) ?: 0;
+        //$limit = trim($this->request->param("limit")) ?: 10;
         $name = trim($this->request->param("name"));
-        $must = trim($this->request->param("must"));
-        $active = trim($this->request->param("active"));
+        $communityId = trim($this->request->param("communityId"));
 
         $where = [];
-
+        $where[] = ["h.status", "<>", 3];
         if ($name) {
-            $where[] = ["name", "like", "%" . $name . "%"];
-        }
-        if ($type) {
-            $where[] = ["type", "=", $type];
+            $where[] = ["h.name", "like", "%" . $name . "%"];
         }
-        if ($must) {
-            $where[] = ["must", "=", $must];
-        }
-        if ($active) {
-            $where[] = ["active", "=", $active];
+        if ($communityId) {
+            $where[] = ["h.communityId", "=", $communityId];
         }
 
+        //$count = Db::table("nhc_hospital")->alias("h")->leftJoin("nhc_medical_community mc", "mc.id=h.communityId")->where($where)->count();
+        $rows = Db::table("nhc_hospital")->alias("h")->leftJoin("nhc_medical_community mc", "mc.id=h.communityId")
+                        ->field("h.*,mc.name as medicalCommunityName")
+                        ->where($where)->order("mc.num asc,h.num asc,h.createTime " . $order)
+                        ->select()->toArray();
 
-        $count = \app\admin\model\CurrencyFiletype::where($where)->count();
-        if ($count > 0) {
-            $rows = \app\admin\model\CurrencyFiletype::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();
-            $typeName = DictApi::selectByParentCode("common_declareType");
-            foreach ($rows as $k => &$v) {
-                $v['typeName'] = $typeName[$v['type']];
-                $v['templateUrl'] = getStoragePath($v['templateUrl']);
-            }
-        } else {
-            $rows = [];
-        }
+        return $rows;
+    }
 
-        return ["total" => $count, "rows" => $rows];
+    public function add() {
+        $where = [];
+        $where[] = ["status", "<>", 3];
+        $medicalCommunities = Db::table("nhc_medical_community")->where($where)->order("num asc")->select()->toArray();
+        return view("edit", ["medicalCommunities" => $medicalCommunities]);
     }
 
-    public function currencyFiletype_add() {
-        return view("");
+    public function edit() {
+        $id = \StrUtil::getRequestDecodeParam($this->request, 'id');
+        $info = Db::table("nhc_hospital")->where("id", $id)->find();
+        $where = [];
+        $where[] = ["status", "<>", 3];
+        $medicalCommunities = Db::table("nhc_medical_community")->where($where)->order("num asc")->select()->toArray();
+        return view("edit", ["row" => $info, "medicalCommunities" => $medicalCommunities]);
     }
 
-    public function add() {
+    public function upsert() {
         $response_obj = new \StdClass();
-        $name = trim($this->request['name']);
-        if (\StrUtil::isEmpOrNull($name)) {
-            $response_obj->code = 500;
-            $response_obj->msg = '附件名称不能为空';
-            return \StrUtil::back($response_obj, 'CurrencyFiletypeInfoDlg.callBack');
-        }
-        $type = trim($this->request['type']);
-        if (\StrUtil::isEmpOrNull($type)) {
-            $response_obj->code = 500;
-            $response_obj->msg = '申报类别不能为空';
-            return \StrUtil::back($response_obj, 'CurrencyFiletypeInfoDlg.callBack');
-        }
-        $api = trim($this->request['api']);
-        if (\StrUtil::isEmpOrNull($api)) {
-            $response_obj->code = 500;
-            $response_obj->msg = 'api不能为空';
-            return \StrUtil::back($response_obj, 'CurrencyFiletypeInfoDlg.callBack');
-        }
-        $must = trim($this->request['must']);
-        if (\StrUtil::isEmpOrNull($must)) {
-            $response_obj->code = 500;
-            $response_obj->msg = '是否必传不能为空';
-            return \StrUtil::back($response_obj, 'CurrencyFiletypeInfoDlg.callBack');
-        }
-        $active = trim($this->request['active']);
-        if (\StrUtil::isEmpOrNull($active)) {
-            $response_obj->code = 500;
-            $response_obj->msg = '是否有效不能为空';
-            return \StrUtil::back($response_obj, 'CurrencyFiletypeInfoDlg.callBack');
-        }
-        $sn = trim($this->request['sn']);
-        if (\StrUtil::isEmpOrNull($sn)) {
-            $response_obj->code = 500;
-            $response_obj->msg = '排序不能为空';
-            return \StrUtil::back($response_obj, 'CurrencyFiletypeInfoDlg.callBack');
-        }
-
-
-        if ($this->request['templateFile']) {
-            $uploadapi = new UploadApi();
-            $file_check_res = $uploadapi->uploadOne($this->request->file('templateFile'), 'system');
-            if ($file_check_res->code == 500) {
-                return \StrUtil::back($file_check_res, "CurrencyFiletypeInfoDlg.callBack");
+        $response_obj->code = 500;
+        $id = \StrUtil::getRequestDecodeParam($this->request, 'id');
+        $where = [];
+        if ($id) {
+            $info = Db::table("nhc_hospital")->where("id", $id)->find();
+            if (!$info) {
+                $response_obj->msg = '找不到记录';
+                return \StrUtil::back($response_obj, 'HospitalInfo.callBack');
             }
-            $templateUrl = $file_check_res->filepath;
-        } else {
-            $templateUrl = "";
+            $where[] = ["id", "<>", $id];
         }
 
+        $name = trim($this->request['name']);
+        if (\StrUtil::isEmpOrNull($name)) {
+            $response_obj->msg = '医院名称不能为空';
+            return \StrUtil::back($response_obj, 'HospitalInfo.callBack');
+        }
+        $where[] = ["name", "=", $name];
+        $repeat = Db::table("nhc_hospital")->where($where)->find();
+
+        if ($repeat) {
+            $response_obj->msg = '医院名称已经被使用';
+            return \StrUtil::back($response_obj, 'HospitalInfo.callBack');
+        }
+        $communityId = trim($this->request['communityId']);
+        if (!$communityId) {
+            $response_obj->msg = '请选择医院所属医共体';
+            return \StrUtil::back($response_obj, 'HospitalInfo.callBack');
+        }
+        $isGeneral = trim($this->request['isGeneral']);
+        if (!$isGeneral) {
+            $response_obj->msg = '请选择是否总院(当前医共体)';
+            return \StrUtil::back($response_obj, 'HospitalInfo.callBack');
+        }
+
+        $num = trim($this->request['num']);
+        if (\StrUtil::isNotEmpAndNull($num) && !is_numeric($num)) {
+            $response_obj->msg = '序号只能是数字';
+            return \StrUtil::back($response_obj, 'HospitalInfo.callBack');
+        }
+        $status = trim($this->request['status']);
+        if (\StrUtil::isEmpOrNull($status)) {
+            $response_obj->msg = '启用状态不能为空';
+            return \StrUtil::back($response_obj, 'HospitalInfo.callBack');
+        }
+        Db::startTrans();
+        try {
+            if ($isGeneral == 1) {
+                //各医共体下最多仅有一家总院,检查是否有其它设置,如有,变更为2,当前设为1
+                $where = [];
+                $where[] = ["communityId", "=", $communityId];
+                $where[] = ["isGeneral", "=", 1];
+                if ($id) {
+                    $where[] = ["id", "<>", $id];
+                }
+                $updOther["isGeneral"] = 2;
+                $updOther["updateTime"] = date("Y-m-d H:i:s");
+                $updOther["updateUser"] = $this->user["uid"];
+                Db::table("nhc_hospital")->where($where)->save($updOther);
+            }
 
-        $data = [
-            'id' => getStringId(),
-            'type' => $type,
-            'name' => $name,
-            'api' => $api,
-            'must' => $must,
-            'active' => $active,
-            'sn' => $sn,
-            'checkCompany' => '1158293574504660993',
-            'description' => $this->request['description'],
-            'createTime' => date("Y-m-d H:i:s"),
-            'createUser' => session('user')['uid'],
-            'templateUrl' => $templateUrl
-        ];
-
-        \app\admin\model\CurrencyFiletype::create($data);
-        $response_obj->code = 200;
-        $response_obj->msg = '添加成功';
-        return \StrUtil::back($response_obj, "CurrencyFiletypeInfoDlg.callBack");
-    }
-
-    public function currencyFiletype_update() {
-        $id = trim($this->request->get('id'));
-        if (\StrUtil::isEmpOrNull($id)) {
-            return json(['msg' => 'id不能为空']);
+            $data["name"] = $name;
+            $data["communityId"] = $communityId;
+            $data["isGeneral"] = $isGeneral;
+            $data["status"] = $status;
+            $data["num"] = $num;
+            $data["description"] = \StrUtil::getRequestDecodeParam($this->request, "description");
+            if ($id) {
+                $data["id"] = $id;
+                $data["updateTime"] = date("Y-m-d H:i:s");
+                $data["updateUser"] = $this->user['uid'];
+                Db::table("nhc_hospital")->save($data);
+            } else {
+                $data["createTime"] = date("Y-m-d H:i:s");
+                $data["createUser"] = $this->user['uid'];
+                Db::table("nhc_hospital")->insert($data);
+            }
+            Db::commit();
+            $response_obj->code = 200;
+            $response_obj->msg = '修改成功';
+            return \StrUtil::back($response_obj, "HospitalInfo.callBack");
+        } catch (\Exception $e) {
+            Db::rollback();
+            $response_obj->msg = $e->getMessage();
+            return \StrUtil::back($response_obj, "HospitalInfo.callBack");
         }
-        $cft = \app\admin\model\CurrencyFiletype::findOrEmpty($id);
-        return view("", ['item' => $cft]);
     }
 
-    public function update() {
-        $response_obj = new \StdClass();
+    public function setGeneral() {
         $id = \StrUtil::getRequestDecodeParam($this->request, 'id');
         if (\StrUtil::isEmpOrNull($id)) {
-            $response_obj->code = 500;
-            $response_obj->msg = 'id不能为空';
-            return \StrUtil::back($response_obj, 'CurrencyFiletypeInfoDlg.callBack');
-        }
-        $cft = \app\admin\model\CurrencyFiletype::findOrEmpty($id);
-        if (!$cft) {
-            $response_obj->code = 500;
-            $response_obj->msg = '找不到记录';
-            return \StrUtil::back($response_obj, 'CurrencyFiletypeInfoDlg.callBack');
-        }
-
-        $cft->name = $name = trim($this->request['name']);
-        if (\StrUtil::isEmpOrNull($name)) {
-            $response_obj->code = 500;
-            $response_obj->msg = '附件名称不能为空';
-            return \StrUtil::back($response_obj, 'CurrencyFiletypeInfoDlg.callBack');
-        }
-        $cft->type = $type = trim($this->request['type']);
-        if (\StrUtil::isEmpOrNull($type)) {
-            $response_obj->code = 500;
-            $response_obj->msg = '申报类别不能为空';
-            return \StrUtil::back($response_obj, 'CurrencyFiletypeInfoDlg.callBack');
-        }
-        $cft->api = $api = trim($this->request['api']);
-        if (\StrUtil::isEmpOrNull($api)) {
-            $response_obj->code = 500;
-            $response_obj->msg = 'api不能为空';
-            return \StrUtil::back($response_obj, 'CurrencyFiletypeInfoDlg.callBack');
-        }
-        $cft->must = $must = trim($this->request['must']);
-        if (\StrUtil::isEmpOrNull($must)) {
-            $response_obj->code = 500;
-            $response_obj->msg = '是否必传不能为空';
-            return \StrUtil::back($response_obj, 'CurrencyFiletypeInfoDlg.callBack');
-        }
-        $cft->active = $active = trim($this->request['active']);
-        if (\StrUtil::isEmpOrNull($active)) {
-            $response_obj->code = 500;
-            $response_obj->msg = '是否有效不能为空';
-            return \StrUtil::back($response_obj, 'CurrencyFiletypeInfoDlg.callBack');
-        }
-        $cft->sn = $sn = trim($this->request['sn']);
-        if (\StrUtil::isEmpOrNull($sn)) {
-            $response_obj->code = 500;
-            $response_obj->msg = '排序不能为空';
-            return \StrUtil::back($response_obj, 'CurrencyFiletypeInfoDlg.callBack');
+            return json(['code' => 500, 'msg' => '缺少参数']);
         }
-        $files = $this->request->file();
 
-
-        if (array_key_exists('templateFile', $files)) {
-            $uploadapi = new UploadApi();
-            $file_check_res = $uploadapi->uploadOne($this->request->file('templateFile'), 'system');
-            if ($file_check_res->code == 500) {
-                return \StrUtil::back($file_check_res, "CurrencyFiletypeInfoDlg.callBack");
-            }
-            $cft->templateUrl = $file_check_res->filepath;
-        } else {
-            $cft->templateUrl = "";
+        $info = Db::table("nhc_hospital")->where("id", $id)->find();
+
+        if (!$info) {
+            return json(['code' => 500, 'msg' => '没有查询到对应医院信息']);
+        }
+        $communityId = $info["communityId"];
+        Db::startTrans();
+        try {
+            //各医共体下最多仅有一家总院,检查是否有其它设置,如有,变更为2,当前设为1
+            $where = [];
+            $where[] = ["communityId", "=", $communityId];
+            $where[] = ["isGeneral", "=", 1];
+            $where[] = ["id", "<>", $id];
+            $updOther["isGeneral"] = 2;
+            $updOther["updateTime"] = date("Y-m-d H:i:s");
+            $updOther["updateUser"] = $this->user["uid"];
+            Db::table("nhc_hospital")->where($where)->save($updOther);
+
+            $updOther["id"] = $id;
+            $updOther["isGeneral"] = 1;
+            Db::table("nhc_hospital")->save($updOther);
+            Db::commit();
+            return json(['code' => 200, 'msg' => "设置成功"]);
+        } catch (\Exception $e) {
+            Db::rollback();
+            return json(['code' => 500, 'msg' => $e->getMessage()]);
         }
-
-        $cft->updateTime = date("Y-m-d H:i:s");
-        $cft->updateUser = session('user')['uid'];
-        $cft->save();
-        $response_obj->code = 200;
-        $response_obj->msg = '修改成功';
-        return \StrUtil::back($response_obj, "CurrencyFiletypeInfoDlg.callBack");
     }
 
     public function delete() {
-        $id = \StrUtil::getRequestDecodeParam($this->request, 'currencyFiletypeId');
+        $id = \StrUtil::getRequestDecodeParam($this->request, 'id');
         if (\StrUtil::isEmpOrNull($id)) {
             return json(['code' => 500, 'msg' => '缺少参数']);
         }
-        \app\admin\model\CurrencyFiletype::destroy($id);
-        return json(['code' => 200, 'msg' => '删除成功']);
+        $data["id"] = $id;
+        $data["status"] = 3;
+        $data["updateTime"] = date("Y-m-d H:i:s");
+        $data["updateUser"] = $this->user["uid"];
+        try {
+            Db::table("nhc_hospital")->save($data);
+            return json(['code' => 200, 'msg' => "删除成功"]);
+        } catch (\Exception $e) {
+            return json(['code' => 500, 'msg' => $e->getMessage()]);
+        }
     }
 
 }

+ 28 - 4
app/admin/view/nhc/hospital/edit.html

@@ -2,7 +2,7 @@
 {block name="content"}
 <div class="ibox float-e-margins">
     <div class="ibox-content">
-        <form id="medicalCommunityInfoForm" action="/admin/nhc.medical_community/upsert" method="post" target="hiddenIframe">
+        <form id="hospitalInfoForm" action="/admin/nhc.hospital/upsert" method="post" target="hiddenIframe">
             <div class="form-horizontal">
                 <input id="id" name="id" value="{$row.id}" type="hidden"/>
                 <div class="row">
@@ -13,6 +13,17 @@
                                 <input class="form-control" id="name" name="name" value="{$row.name}"/>
                             </div>
                         </div>
+                        <div class="form-group">
+                            <label class="col-sm-3 control-label">
+                                是否总院
+                            </label>
+                            <div class="col-sm-9">
+                                <select class="form-control" id="isGeneral" name="isGeneral" selectVal="{$row.isGeneral}">
+                                    <option value="2">否</option>
+                                    <option value="1">是</option>
+                                </select>
+                            </div>
+                        </div>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">
                                 是否启用
@@ -26,6 +37,19 @@
                         </div>
                     </div>
                     <div class="col-sm-6">
+                        <div class="form-group">
+                            <label class="col-sm-3 control-label">
+                                医共体
+                            </label>
+                            <div class="col-sm-9">
+                                <select class="form-control" id="communityId" name="communityId" selectVal="{$row.communityId}">                             
+                                    <option value=""></option>
+                                    {volist name="$medicalCommunities" id="mc"}                                    
+                                    <option value="{$mc.id}">{$mc.name}</option>
+                                    {/volist}
+                                </select>
+                            </div>
+                        </div>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">
                                 排序
@@ -46,10 +70,10 @@
                 </div>
                 <div class="row btn-group-m-t">
                     <div class="col-sm-12" style="text-align: center;">
-                        <button type="button" class="btn btn-sm btn-info " onclick="MedicalCommunityInfo.editSubmit()" id="ensure">
+                        <button type="button" class="btn btn-sm btn-info " onclick="HospitalInfo.editSubmit()" id="ensure">
                             <i class="fa fa-check"></i>&nbsp;提交
                         </button>
-                        <button type="button" class="btn btn-sm btn-danger " onclick="MedicalCommunityInfo.close()" id="cancel">
+                        <button type="button" class="btn btn-sm btn-danger " onclick="HospitalInfo.close()" id="cancel">
                             <i class="fa fa-eraser"></i>&nbsp;取消
                         </button>
                     </div>
@@ -60,6 +84,6 @@
 </div>
 <iframe id="hiddenIframe" name="hiddenIframe" style="display: none;"></iframe>
 <script type="text/javascript">
-    document.write('<script src="/static/modular/nhc/medicalCommunity/medicalCommunity_info.js?v=' + (new Date()).getTime() + '"><\/script>');
+    document.write('<script src="/static/modular/nhc/hospital/hospital_info.js?v=' + (new Date()).getTime() + '"><\/script>');
 </script>
 {/block}

+ 7 - 4
app/admin/view/nhc/hospital/index.html

@@ -29,7 +29,7 @@
                                     </div>
                                     <select class="form-control" id="communityId">
                                         <option value=""></option>
-                                        {volist name="mediaCommunities" id="mc"}                                        
+                                        {volist name="medicalCommunities" id="mc"}                                        
                                         <option value="{$mc.id}">{$mc.name}</option>
                                         {/volist}
                                     </select>
@@ -39,17 +39,20 @@
                                 <button type="button" class="btn btn-sm btn-primary" onclick="Hospital.search()">
                                     <i class="fa fa-search"></i>&nbsp;搜索
                                 </button>
+                                <button type="button" class="btn btn-sm btn-primary" onclick="Hospital.reset()">
+                                    <i class="fa fa-trash"></i>&nbsp;重置
+                                </button>
                             </div>
                         </div>
                         <div class="hidden-xs" id="hospitalTableToolbar" role="group">
                             {if condition="chkCommission('/admin/nhc.hospital/add','')"}
                             <button type="button" class="btn btn-sm btn-primary" onclick="Hospital.openAddHospital()">
-                                <i class="fa fa-plus"></i>&nbsp;添加医院
+                                <i class="fa fa-plus"></i>&nbsp;添加
                             </button>
                             {/if}                            
                             {if condition="chkCommission('/admin/nhc.hospital/edit','')"}
                             <button type="button" class="btn btn-sm btn-primary button-margin" onclick="Hospital.openChangeHospital()">
-                                <i class="fa fa-edit"></i>&nbsp;修改医院
+                                <i class="fa fa-edit"></i>&nbsp;修改
                             </button>
                             {/if}                       
                             {if condition="chkCommission('/admin/nhc.hospital/setGeneral','')"}
@@ -59,7 +62,7 @@
                             {/if}
                             {if condition="chkCommission('/admin/hospital.hospital/delete','')"}
                             <button type="button" class="btn btn-sm btn-primary button-margin" onclick="Hospital.delHospital()">
-                                <i class="fa fa-remove"></i>&nbsp;删除医院
+                                <i class="fa fa-remove"></i>&nbsp;删除
                             </button>
                             {/if}
                         </div>

+ 3 - 0
app/admin/view/nhc/medical_community/index.html

@@ -24,6 +24,9 @@
                                 <button type="button" class="btn btn-sm btn-primary" onclick="MedicalCommunity.search()">
                                     <i class="fa fa-search"></i>&nbsp;搜索
                                 </button>
+                                <button type="button" class="btn btn-sm btn-primary" onclick="MedicalCommunity.reset()">
+                                    <i class="fa fa-trash"></i>&nbsp;重置
+                                </button>
                             </div>
                         </div>
                         <div class="hidden-xs" id="medicalCommunityTableToolbar" role="group">

+ 69 - 9
public/static/modular/nhc/hospital/hospital.js

@@ -15,9 +15,17 @@ Hospital.initColumn = function () {
     var columns = [
         {field: 'selectItem', radio: true},
         {title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
-        {title: '医院名称', field: 'name', align: 'center', valign: 'middle', sortable: true},
+        {title: '医院名称', field: 'name', align: 'center', valign: 'middle', sortable: true,
+            formatter: function (value, row) {
+                if (row.isGeneral == 1) {
+                    return value + "(总院)";
+                }
+                return value;
+            }
+        },
         {title: '医共体', field: 'medicalCommunityName', align: 'center', valign: 'middle', sortable: true},
-        {title: '是否总院', field: 'isGeneral', align: 'center', valign: 'middle', sortable: true},
+        {title: '备注', field: 'description', align: 'center', valign: 'middle', sortable: true},
+        {title: '排序', field: 'num', align: 'center', valign: 'middle', sortable: true},
         {title: '状态', field: 'status', align: 'center', valign: 'middle', sortable: true,
             formatter: function (value) {
                 if (value == 1) {
@@ -77,6 +85,31 @@ Hospital.openChangeHospital = function () {
     }
 };
 
+/**
+ * 设为总院
+ */
+Hospital.setGeneral = function () {
+    if (this.check()) {
+
+        var operation = function () {
+            var ajax = new $ax(Feng.ctxPath + "/admin/nhc.hospital/setGeneral", function (data) {
+                if (data.code == 200) {
+                    Feng.success(data.msg);
+                    $('#hospitalTable').bootstrapTable('refresh');
+                } else {
+                    Feng.error(data.msg);
+                }
+            }, function (data) {
+                Feng.error("设置失败!" + data.responseJSON.message + "!");
+            });
+            ajax.set("id", Hospital.seItem.id);
+            ajax.start();
+        };
+
+        Feng.confirm("是否设置该医院为其所在医共体的总院?", operation);
+    }
+}
+
 /**
  * 删除
  */
@@ -86,7 +119,7 @@ Hospital.delHospital = function () {
         var operation = function () {
             var ajax = new $ax(Feng.ctxPath + "/admin/nhc.hospital/delete", function (data) {
                 Feng.success("删除成功!");
-                Hospital.table.refresh();
+                $('#hospitalTable').bootstrapTable('refresh');
             }, function (data) {
                 Feng.error("删除失败!" + data.responseJSON.message + "!");
             });
@@ -106,13 +139,40 @@ Hospital.search = function () {
 
     queryData['communityId'] = $("#communityId").val();
     queryData['name'] = $("#name").val();
-
-    Hospital.table.refresh({query: queryData});
+    $('#hospitalTable').bootstrapTable('refresh', {query: queryData});
+}
+/**
+ * 重置
+ */
+Hospital.reset = function () {
+    $("#name").val("");
+    $("#communityId").val("");
 }
 
 $(function () {
-    var defaultColunms = Hospital.initColumn();
-    var table = new BSTable(Hospital.id, "/admin/nhc.hospital/list", defaultColunms);
-    table.init();
-    Hospital.table = table;
+
+    Hospital.table = $('#hospitalTable').bootstrapTable({
+        url: "/admin/nhc.hospital/list",
+        method: 'POST',
+        contentType: "application/x-www-form-urlencoded; charset=UTF-8",
+        search: false, // 是否显示表格搜索,此搜索是客户端搜索,不会进服务端
+        showRefresh: false, // 是否显示刷新按钮
+        clickToSelect: true, // 是否启用点击选中行
+        singleSelect: false, // 设置True 将禁止多选
+        striped: true, // 是否显示行间隔色
+        pagination: false, // 设置为 true 会在表格底部显示分页条
+        paginationHAlign: "left",
+        paginationDetailHAlign: "right",
+        sidePagination: "client", // 设置在哪里进行分页,可选值为 'client' 或者 'server'
+        pageNumber: 1, //初始化加载第一页,默认第一页
+        pageSize: 10, //每页的记录行数(*)
+        pageList: [10, 25, 50, 100, 500, 1000, 1500], //可供选择的每页的行数(*)
+        maintainSelected: true, //全表全选需要开启
+        showColumns: false,
+        columns: Hospital.initColumn(),
+        onDblClickRow: function () {
+            Hospital.openChangeHospital();
+        }
+
+    });
 });

+ 135 - 0
public/static/modular/nhc/hospital/hospital_info.js

@@ -0,0 +1,135 @@
+/**
+ * 医共体
+ */
+var HospitalInfo = {
+    infoData: {},
+    validateFields: {
+        name: {
+            validators: {
+                notEmpty: {
+                    message: '医院名称不能为空'
+                }
+            }
+        },
+        communityId: {
+            validators: {
+                notEmpty: {
+                    message: '请选择医共体'
+                }
+            }
+        },
+        isGeneral: {
+            validators: {
+                notEmpty: {
+                    message: '请选择是否总院'
+                }
+            }
+        },
+        status: {
+            validators: {
+                notEmpty: {
+                    message: '启用状态不能为空'
+                }
+            }
+        },
+        num: {
+            validators: {
+                notEmpty: {
+                    message: '排序不能为空'
+                },
+                regexp: {
+                    regexp: /^\d+$/,
+                    message: '只能输入数字'
+                }
+            }
+        }
+    }
+};
+
+/**
+ * 清除数据
+ */
+HospitalInfo.clearData = function () {
+    this.infoData = {};
+}
+
+/**
+ * 设置对话框中的数据
+ *
+ * @param key 数据的名称
+ * @param val 数据的具体值
+ */
+HospitalInfo.set = function (key, val) {
+    this.infoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
+    return this;
+}
+
+/**
+ * 设置对话框中的数据
+ *
+ * @param key 数据的名称
+ * @param val 数据的具体值
+ */
+HospitalInfo.get = function (key) {
+    return $("#" + key).val();
+}
+
+/**
+ * 关闭此对话框
+ */
+HospitalInfo.close = function () {
+    parent.layer.close(window.parent.Hospital.layerIndex);
+}
+
+/**
+ * 收集数据
+ */
+HospitalInfo.collectData = function () {
+    this.set('id')
+            .set('name')
+            .set('communityId')
+            .set('isGeneral')
+            .set('status')
+            .set('num')
+            .set('description');
+}
+
+/**
+ * 验证数据是否为空
+ */
+HospitalInfo.validate = function () {
+    $('#hospitalInfoForm').data("bootstrapValidator").resetForm();
+    $('#hospitalInfoForm').bootstrapValidator('validate');
+    return $("#hospitalInfoForm").data('bootstrapValidator').isValid();
+}
+
+/**
+ * 提交修改
+ */
+HospitalInfo.editSubmit = function () {
+    this.clearData();
+    this.collectData();
+    if (!this.validate()) {
+        return;
+    }
+    $('#hospitalInfoForm')[0].submit();
+}
+
+//回调
+HospitalInfo.callBack = function (data) {
+    if (data.code == "200") {
+        Feng.success(data.msg);
+        window.parent.Hospital.table.refresh();
+        HospitalInfo.close();
+    } else {
+        Feng.error(data.msg);
+    }
+}
+
+$(function () {
+    //下拉框数据回显
+    $("select").each(function () {
+        $(this).val($(this).attr("selectVal"));
+    });
+    Feng.initValidator("hospitalInfoForm", HospitalInfo.validateFields);
+});

+ 6 - 0
public/static/modular/nhc/medicalCommunity/medicalCommunity.js

@@ -108,6 +108,12 @@ MedicalCommunity.search = function () {
 
     MedicalCommunity.table.refresh({query: queryData});
 }
+/**
+ * 重置
+ */
+MedicalCommunity.reset = function () {
+    $("#name").val("");
+}
 
 $(function () {
     var defaultColunms = MedicalCommunity.initColumn();