diff options
Diffstat (limited to '97suifangqa/apps/indicator')
5 files changed, 103 insertions, 24 deletions
diff --git a/97suifangqa/apps/indicator/models.py b/97suifangqa/apps/indicator/models.py index 0a3c8a5..b992a1f 100644 --- a/97suifangqa/apps/indicator/models.py +++ b/97suifangqa/apps/indicator/models.py @@ -396,15 +396,16 @@ class IndicatorRecord(models.Model): # {{{ NOTE: convert record data to 'standard unit' before comparison """ sind = self.indicator - # unit relation - unit_rel = self.unit.relation - v = sympy.symbols('v') - rel_sym = sympy.sympify(unit_rel) - # error message - errmsg = u"'%s' 求值错误,请检查只含有变量 'v'" % unit_rel # check if sind.dataType in [sind.FLOAT_TYPE, sind.RANGE_TYPE, sind.FLOAT_RANGE_TYPE]: + # unit relation + unit_rel = self.unit.relation + v = sympy.symbols('v') + rel_sym = sympy.sympify(unit_rel) + # error message + errmsg = u"'%s' 求值错误,请检查只含有变量 'v'" % unit_rel + # check InnateConfine for the Indicator first if not sind.check_confine(): return False # InnateConfine is ok diff --git a/97suifangqa/apps/indicator/static/css/edit_history_data.css b/97suifangqa/apps/indicator/static/css/edit_history_data.css index 9775539..49005be 100644 --- a/97suifangqa/apps/indicator/static/css/edit_history_data.css +++ b/97suifangqa/apps/indicator/static/css/edit_history_data.css @@ -1,3 +1,26 @@ +/* + * How To Change Radio Button Checkbox Style in CSS: + * http://viralpatel.net/blogs/css-radio-button-checkbox-background/ + */ +input[type="radio"] { + display: none; + margin: 4px; + vertical-align: middle; +} +input[type="radio"] + label { + display: inline-block; + height: 17px; + line-height: 17px; + margin-right: 2px; + padding: 2px 7px; + background-color: #F3F3F1; + border: 1px solid #9C9C9C; +} +input[type="radio"]:checked + label { + background-image: none; + background-color: #99CC33; +} + #edit_history_data_container { width: 588px; height: 180px; @@ -147,6 +170,10 @@ .edit_history_data_content .editing_data .data .invalid { border: 2px solid red; } +.edit_history_data_content .editing_data .data .radio_input { + margin-right: 8px; + float: left; +} .edit_history_data_content .editing_data .data .data_input { width: 200px; height: 17px; diff --git a/97suifangqa/apps/indicator/static/javascripts/edit_history_data.js b/97suifangqa/apps/indicator/static/javascripts/edit_history_data.js index f4deafd..e0dff4a 100644 --- a/97suifangqa/apps/indicator/static/javascripts/edit_history_data.js +++ b/97suifangqa/apps/indicator/static/javascripts/edit_history_data.js @@ -74,10 +74,21 @@ $(document).ready(function(){ }); // }}} + // initalize // set datepicker 'date_input' value var date_init = $.datepicker.parseDate('yy-mm-dd', $(".date_input").attr('value')); $(".date_input").datepicker("setDate", date_init); + // select radio button according to the original value + if ($(".editing_data .radio_input").length) { + $(".radio_input input:radio").prop("checked", false); + } + if (record.value === '-') { + $(".radio_input #minus_r").prop("checked", true); + } + else { + $(".radio_input #plus_r").prop("checked", true); + } // record data validate {{{ // date {{{ @@ -314,9 +325,41 @@ $(document).ready(function(){ else if (data_type == DATA_TYPES.FLOAT_RANGE_TYPE) { // TODO } - else if (data_type == DATA_TYPES.PM_TYPE) { + else if (data_type == DATA_TYPES.PM_TYPE) { // {{{ // TODO - } + var radioinput_help = '<p>请直接点击选择</p>'; + // tooltip + $(".radio_input").qtip({ + id: 'radioinput', + prerender: false, + content: { + text: radioinput_help + }, + position: { + my: 'bottom left', + at: 'top right' + }, + show: { + event: 'mouseenter' + }, + hide: { + event: 'mouseleave unfocus' + } + }); + // validate + $(".radio_input").on('validate', null, function() { + if ($(".radio_input input:radio:checked").length != 1) { + var qtip_content = '<p>请选择化验结果</p>'; + $(this).qtip('api').set('content.text', + qtip_content); + $(this).qtip('api').show(); + } + else { + // valid + record_data.value = $(".radio_input input:radio:checked").val(); + } + }); + } // }}} else { // unknown return false; diff --git a/97suifangqa/apps/indicator/templates/indicator/popup/EditHistoryData.html b/97suifangqa/apps/indicator/templates/indicator/popup/EditHistoryData.html index 70ec582..340057b 100644 --- a/97suifangqa/apps/indicator/templates/indicator/popup/EditHistoryData.html +++ b/97suifangqa/apps/indicator/templates/indicator/popup/EditHistoryData.html @@ -44,15 +44,10 @@ 'PM_TYPE': '{{ indicator_obj.PM_TYPE }}' }; var data_type = '{{ indicator_obj.dataType }}'; + // indicator record + var record = $.parseJSON('{{ record_json|safe }}'); // indicator confine - var confine = { - 'val_norm': '{{ confine_dict|dict_get:"val_norm" }}', - 'human_min': {{ confine_dict|dict_get:"human_min" }}, - 'human_max': {{ confine_dict|dict_get:"human_max" }}, - 'math_min': {{ confine_dict|dict_get:"math_min" }}, - 'math_max': {{ confine_dict|dict_get:"math_max" }}, - 'math_range_html': '{{ confine_dict|dict_get:"math_range_html" }}' - }; + var confine = $.parseJSON('{{ confine_json|safe }}'); // range symbol: <low_num> <symbol> <high_num> var range_symbol = '~'; @@ -133,14 +128,22 @@ <input class="data_input to_validate" type="text" value="{{ record_dict|dict_get:"value_text" }}" autocomplete="off" /> {% elif indicator_obj.dataType == indicator_obj.PM_TYPE %} {# PM_TYPE #} - <div class="radio_button"> - <span class="button"><input class="data_input to_validate" type="radio" name="pm_data" value="minus" /></span> - <span class="text">阴性(-)</span> + <div class="radio_input to_validate"> + <input type="radio" id="minus_r" name="pm_data" value="-" /> + <label for="minus_r">阴性(-)</label> + <input type="radio" id="plus_r" name="pm_data" value="+" /> + <label for="plus_r">阳性(+)</label> + </div> + <!-- + <div class="radio_input"> + <span class="radio_s"><input class="to_validate" type="radio" name="pm_data" value="minus" /></span> + <span class="radio_text">阴性(-)</span> </div> - <div class="radio_button"> - <span class="button"><input class="data_input to_validate" type="radio" name="pm_data" value="plus" /></span> - <span class="text">阳性(+)</span> + <div class="radio_input"> + <span class="radio_s"><input class="to_validate" type="radio" name="pm_data" value="plus" /></span> + <span class="radio_text">阳性(+)</span> </div> + --> {% else %} {# UNKNOWN TYPE #} ERROR: unknown data type diff --git a/97suifangqa/apps/indicator/views.py b/97suifangqa/apps/indicator/views.py index aa05ab4..aa51663 100644 --- a/97suifangqa/apps/indicator/views.py +++ b/97suifangqa/apps/indicator/views.py @@ -824,16 +824,21 @@ def indicator_edithistorydata(request): 'date': record_date.isoformat(), 'value_html': record_value_html, 'value_text': record_value_text, + 'value': record_value, + 'val_min': record_val_min, + 'val_max': record_val_max, 'unit_name': record_unit_name, 'unit_symbol': record_unit_symbol, 'is_normal': record_is_normal, } data = { 'confine_dict': confine_dict, + 'confine_json': json.dumps(confine_dict), 'indicator_obj': ind_obj, 'indicator_dict': ind_dict, 'record_obj': record_obj, 'record_dict': record_dict, + 'record_json': json.dumps(record_dict), } # return render(request, template, data) @@ -1310,8 +1315,8 @@ def ajax_modify_record(request): and add a 'RecordHistory' for the record """ data = {'failed': True, 'error_code': 1, 'error_string': 'unknown'} - if request.method == 'POST': - #if request.is_ajax() and request.method == 'POST': + #if request.method == 'POST': + if request.is_ajax() and request.method == 'POST': print request.POST.dict() record_id = request.POST.get('record_id') date_str = request.POST.get('date') |