Skip to content

SAD SmartBackstage (SAD SB)

renfeisong edited this page Dec 19, 2014 · 23 revisions

开发方法

所有后台页面都用sb_layout.jade模版,只需要定义contentblock,在其中直接写内容即可,不用写页面头部、侧边栏、脚部。例如:

extends ./sb_layout
block content
    p ...

也可以参考 sb_home.jade(访问地址:/backstage

页面对照表

  • 欢迎页面 sb_home.jade
  • 医院管理 sb_hospitals.jade
  • 用户审核 sb_users.jade
  • 科室管理 sb_departments.jade
  • 医生管理 sb_doctors.jade
  • 排班编辑 sb_edit-schedule.jade
  • 预约管理 sb_reservations.jade
  • 修改密码 sb_changePassword.jade

插件

系统已经内置如下 CSS/JavaScript 插件,可以直接使用:

  • Font Awesome
  • jQuery
  • Toastr Notifications
  • iCheck
  • Select2
  • jQuery Validate
  • Bootstrap Editable
  • DataTables
  • Bootstrap 的所有 JavaScript 插件

注意:系统没有内置 Bootstrap 的 CSS 样式

插件的使用

  • 表格展示请使用 DataTables,文档
  • 表格信息编辑请使用 Bootstrap Editable 插件,文档
  • 表单验证请使用 jQuery Validation,文档
  • 通过 URL 参数传递的提示信息不需要处理,由我统一实现

关于样式

  • 虽然系统不内置 Bootstrap 的 CSS 样式,但是内置了我精心准备的 CSS 文件,因此对于基本功能是够用的。
  • 页面统一以一个h2开头,为页面标题
  • input元素、textarea元素都添加form-control
  • table添加table table-striped table-bordered table-hover
  • 按钮(button元素)添加button类,并且有几种颜色可以选择:
    • 绿色:添加green-button
    • 红色:添加red-button
    • 蓝色:添加blue-button
    • 灰色:添加gray-button
  • 标签可以添加label类,并且有多色可选:green-labelblue-labelgray-labelgblue-labellblue-labelyellow-labelred-label(均为类名)。如果想使用小号标签,可以添加xs-label
  • 页面专用 CSS 可以另外建立文件

tab 分页

对于医院、科室、医生管理,涉及管理现有记录和添加新记录两部分。出于后台用户体验的一致性考虑,统一使用 tab 分页的方式实现。

效果可参考:医生管理页面

实现起来非常简单,不需要写 JavaScript 代码。方法如下:

extends ./sb_layout

block content
   h2 医生管理

   ul.nav.nav-tabs(role='tablist')
      li.active(role='presentation')
         a(href='#panel-manage', role='tab', data-toggle='tab') 现有医生管理
      li(role='presentation')
         a(href='#panel-add', role='tab', data-toggle='tab') 添加医生

   div.tab-content
      div#panel-manage.tab-pane.fade.in.active
         h3 现有医生管理
         table#doctor-table.table.table-striped.table-bordered.table-hover
            thead
               tr
                  th id
                  th 姓名
                  th 所属科室
                  th 职称
                  th 描述
                  th 操作
            tbody


      div#panel-add.tab-pane.fade
         h3 添加医生

页面参数文档

所有页面都传的参数:

  • username(管理员用户名)
  • hospitalId(所管理医院的ID)
  • hospitalName(所管理医院的名称)

所有页面:

  • 如果检测到未登录,直接跳转到 /backstage/login

很多页面:

  • 包括login,changePassword,departments,doctors,reservations
  • 可以在URL中传一个:msgType/:message参数,分别表示信息类型(success/fail),以及提示信息(用代号表示)

exports.home = function(request, response) {

渲染主页(sb_home.jade)
无需额外操作

};

exports.login = function(request, response) {

渲染登录页(sb_login.jade)
无需额外操作

};

exports.onLogin = function(request, response) {

接收POST方式发送的数据(password为):
username,password
调用管理员登陆接口
成功就跳转到/backstage(并写cookie)
失败跳转到/backstage/login,添加错误提示wrong_credentials
没有界面

};

exports.logout = function(request, response) {

写cookie
跳转到/login,添加成功提示logout_complete
没有界面

};

exports.changePassword = function(request, response) {

渲染修改密码页(sb_changePassword.jade)

};

exports.onChangePassword = function(request, response) {

接收POST方式发送的数据:
username,originalPassword,newPassword
调用修改密码接口
完成后跳转到/backstage/account,添加成功提示complete或失败提示wrong_credential
没有界面

};

exports.hospitals = function(request, response) {

渲染管理医院页面(sb_hospitals.jade)
传参:
list:(2-2-1)
[
    {
      "id": 1,
      "name": "协和医院",
      "level": "三级甲等", (REV#2~1#)
      "province": "北京",
      "city": "北京",
      "address": "xxxx",
      "telephone": "xxxx",
      "website": "www.google.com",
      "description": "这是一家好医院"
    },{
      "id": 2,
      "name": "昌平医院",
      ...
    }
]

};

exports.departments = function(request, response) {

渲染管理科室页面(sb_departments.jade)
传参:
list:(2-3-1)
[
    {
      "id": 1,
      "name": "xxx",
      "phone": "838141",
      "description": "xxxxxx"
    },
    {
      "id": 2,
      "name": "xxx",
      "phone": "838143",
      "description": "xxxxxx"
    }
]

};

exports.doctors = function(request, response) {

渲染管理医生页面(sb_doctors.jade)
传参:
departments:(2-3-1)
[
    {
      "id": 1,
      "name": "xxx",
      "phone": "838141",
      "description": "xxxxxx"
    },
    {
      "id": 2,
      "name": "xxx",
      "phone": "838143",
      "description": "xxxxxx"
    }
]
list:(2-2-1,需要合并一下)
[
    {
        "id": 2,
        "name": "李四",
        "hospital": "协和医院",
        "department": "口腔科",
        "title": "副主任医师",
        "description": "擅长治疗xxx",
        "photo_url": "http://www.example.com/383d1adc.png"
    },{
        "id": 3,
        "name": "李四",
        "hospital": "协和医院",
        "department": "口腔科",
        "title": "副主任医师",
        "description": "擅长治疗xxx",
        "photo_url": "http://www.example.com/383d1adc.png"
    }
]

};

exports.reservations = function(request, response) {

渲染管理预约页面(sb_reservations.jade)
传参:
list:(3-1-7)
[
    {
		"reservation_id":12345,
		"time":"2014-12-16 08:50:00",
		"price":"23.33",
		"status":"未付款",
		"hospital_name":"XX hospital",
		"department_name":"psychology",
		"doctor_name":"杨伟"
	},{
		"reservation_id":12345,
		"time":"2014-12-16 08:50:00",
		"price":"23.33",
		"status":"未付款",
		"hospital_name":"XX hospital",
		"department_name":"psychology",
		"doctor_name":"程序"
	}
]

};

exports.addHospital = function(request, response) {

接收POST方式发送的数据:
name,level,province,address,telephone,website
调用2-1-3接口
完成后跳转到/backstage/hospitals,添加成功提示complete
没有界面

};

exports.addDepartment = function(request, response) {

接收POST方式发送的数据:
name,hospitalId,phone,description
调用2-3-3接口
完成后跳转到/backstage/departments,添加成功提示complete
没有界面

};

exports.addDoctor = function(request, response) {

接收POST方式发送的数据:
name, hospitalId, departmentId, description, title, price, timeSlots
其中timeSlots为上班时间,格式是一个JSON字符串(day的范围为1-7):
{
	"day": [
		[0, 1, 0],
		[1, 0, 1],
		[1, 0, 1],
		[1, 0, 1],
		[1, 0, 1],
		[1, 0, 1],
		[1, 0, 1]
	]
}
可调用2-2-2以及2-2-6-2接口
完成后跳转到/backstage/account,添加成功提示complete
没有界面

};

exports.editSchedule = function(request, response) {

渲染编辑排班页面(sb_edit-schedule.jade)
接收URL参数id(为医生id)
传参:
doctorId:医生 id
doctorName:姓名
doctorHospital:医院
doctorDepartment:部门
schedule(调2-2-6-1接口):
{
    "week": [
		[1, 0, 1],				//周一  上午,下午,晚上
		[0, 1, 1],
		[0, 1, 1],
		[0, 0, 1],
		[0, 0, 0],
		[1, 1, 1],
		[1, 1, 0]				//周日
	],
	"temp": [ {
		"date": "2014-12-12",
		"period": 0,
		"isWorking": true		//临时加班
	}, {
		"date": "2014-12-12",
		"period": 2,
		"isWorking": false		//临时休假
	}, 
	......
	]
}

};

exports.modifyTempWorking = function(request, response) {

接收POST数据:doctorId,action,date,period
action为add或delete
调用2-2-6-5, 2-2-6-6接口
完成后跳转到/backstage/doctor/<doctor-id>/edit_schedule,添加成功提示add_complete或者delete_complete
没有界面

};

exports.users = function (request, response) {

渲染审核用户页面(sb_users.jade)
传参:
list: (1-2-1)
    [
        {
            "user_id": 233,
            "username": "rongzimeng",
            "id": "13100219930415461X",
            "name": "荣芓萌",
            "phone": "13332333233",
            "email": "rongzimeng@db.com",
            "ip": "127.0.0.1"
        },
        {
            "user_id": 2333,
            "username": "saaby",
            "id": "111111111111111111",
            "name": "萌芓荣",
            "phone": "13332333233",
            "email": "rongzimeng@db.com",
            "ip": "127.0.0.1"
        }
    ]

};