123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>选择居民疾病类型</title>
- <meta name="author" content="yihu.com" />
- <meta name="format-detection" content="telephone=no" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <meta name="apple-mobile-web-app-status-bar-style" content="black" />
-
- <link rel="stylesheet" href="../../../common/cross/css/cross.css" type="text/css" />
- <link rel="stylesheet" href="../../../common/cross/css/cross.ui.css" type="text/css" />
- <link rel="stylesheet" href="../../../css/mui.min.css">
- <link rel="stylesheet" href="../css/xuanzejibing.css">
- <script type="text/javascript" src="../../../js/jquery/2.1.3/jquery.js"></script>
- </head>
- <body>
- <div class="main">
- <div class="h45">
- <div class="demo-comtop">
- <a class="mui-action-back"></a>
- <h1 style="font-size: 100%; margin: .67em 0;">选择居民疾病类型</h1>
- <div class="header-link" style="display: none;">
- <a onclick="submit()" class="c-ccc link">完成</a>
- </div>
- </div>
- </div>
- <div class="doc-mycarder" id="list" style="background: #fff;">
-
- </div>
- </div>
- <script type="text/html" id="disease_temp">
- {{each list as v i}}
- <div class="mui-input-row mui-checkbox mui-left item {{v.code | setDisabled}}">
- <label>{{v.name}}</label>
- <input class="chk-box" data-name="{{v.name}}" value="{{v.code}}" {{v.code | setChecked}} type="checkbox">
- </div>
- {{/each}}
- <div class="mui-input-row mui-checkbox mui-left item item-other">
- <label>无以上疾病</label>
- <input class="chk-box chk-other" value="-1" type="checkbox">
- </div>
- </script>
- <script src="../../../js/mui.min.js" type="text/javascript" charset="utf-8"></script>
- <script src="../../../js/common_http.js" type="text/javascript" charset="utf-8"></script>
- <script src="../../js/common.js" type="text/javascript" charset="utf-8"></script>
- <script src="../../../js/template.js" type="text/javascript" charset="utf-8"></script>
- <script src="../../js/common.js" type="text/javascript" charset="utf-8"></script>
- <script src="../../js/templateHelp.js" type="text/javascript" charset="utf-8"></script>
-
- <script type="text/javascript">
- var postUrl = "doctor/patient_group/patient";
- var self, patiCode, isModify,
- diseases,
- hasSanshi;
-
- mui.plusReady(function() {
- self = plus.webview.currentWebview();
- diseases = self.diseases;
- patiCode = self.patiCode;
-
- if(patiCode)
- $('.header-link').show();
-
- mui.init({
- beforeback: function() {
- if(patiCode){
- if(isModify){
- mui.confirm("您已作了修改,需要保存吗?", "提示", ["不保存", "保存"], function(e) {
- if(e.index == 0) {
- plus.webview.currentWebview().close();
- } else {
- submit();
- }
- })
- return false;
- }
- } else {
- fireOpener();
- }
- }
- });
-
- template.helper("setChecked", function(j) {
- if(!diseases)
- return " ";
- for(var k in diseases){
- if(diseases[k].disease == j){
- var disabled;
- if(diseases[k].signType== '1'){
- hasSanshi = true;
- disabled = "disabled";
- }
- return ' data-old=1 checked=checked data-signType='+ diseases[k].signType
- + ' ' + disabled;
- }
- }
- return "data-signType=2";
- });
-
- template.helper("setDisabled", function(j) {
- if(!diseases)
- return " ";
- for(var k in diseases){
- if(diseases[k].disease == j && diseases[k].signType== '1')
- return ' item-disabled ';
- }
- return " ";
- });
-
- getDiseases();
- });
-
- /**
- * 获取疾病选择
- */
- function getDiseases(){
- sendPost("/common/data/diseases", {}, null, function(res){
- $('#list').html(template("disease_temp", res));
- if(hasSanshi){
- $('.chk-other').attr('disabled', true).parent().addClass('item-disabled');
- // $('.chk-box[value='+ hasSanshi +']').attr('disabled', true).parent().addClass('item-disabled');
- }
-
- initAction();
- })
- }
-
- /**
- * 初始化事件
- */
- function initAction(){
- $('.chk-box').on('change', function(){
- if($(this).hasClass('chk-other'))
- $('.chk-box[value!=-1]').attr('checked', false);
- else
- $('.chk-box[value=-1]').attr('checked', false);
-
- check();
- })
-
- $('.chk-box').on('tap', function(){
- return false;
- })
-
- $('.item').on('tap', function(){
- if($(this).hasClass('item-disabled'))
- return false;
- $(this).find('input:first').click();
- })
- }
-
- /**
- * 判断是否修改
- */
- function check(){
- var old = $('.chk-box[data-old="1"]');
- if($('.chk-box:checked[data-old="1"]').length != old.length
- || $('.chk-box:checked').length > old.length){
- $('.link').removeClass('c-ccc');
- isModify = true;
- }
- else {
- isModify = false;
- $('.link').addClass('c-ccc');
- }
- }
-
- /**
- * 获取选中的数据
- */
- function getChecked(){
- var codes = [];
- var diseases = [];
- var names = [];
- $.each($('.chk-box:checked'), function(i, v) {
- if($(v).val() == -1)
- return;
- codes.push($(v).val());
- diseases.push({disease: $(v).val(), diseaseName: $(v).attr('data-name'), signType: $(v).attr('data-signType')});
- names.push($(v).attr('data-name'));
- });
- if(names.length == 0)
- names.push('无');
- return {codes: codes, diseases: diseases, names: names.join("、")};
- }
-
- /**
- * 更新父页面信息
- * @param {Object} chks
- */
- function fireOpener(chks){
- chks = chks || getChecked();
- mui.fire(self.opener(), "setDiseaseTypes", chks);
- }
-
- /**
- * 提交
- */
- function submit(){
- if(isModify){
- var chks = getChecked();
- sendPost("/doctor/patient/disease_update",
- {patient: patiCode, disease: chks.codes.join(',')},
- null,
- function(res){
- if(res.status == 200){
- fireOpener(chks);
- var huanzheWv = plus.webview.getWebviewById("huanzhe.html");
- if(huanzheWv)
- mui.fire(huanzheWv, "refresh");
- mui.toast('修改成功!');
- plus.webview.currentWebview().close();
- } else{
- mui.toast(res.msg);
- }
- }
- )
-
- }
- }
- </script>
- </body>
- </html>
|