diff options
Diffstat (limited to '97suifangqa')
-rw-r--r-- | 97suifangqa/apps/indicator/models.py | 26 | ||||
-rw-r--r-- | 97suifangqa/apps/indicator/static/css/edit_history_data.css | 11 | ||||
-rw-r--r-- | 97suifangqa/apps/indicator/static/css/sheet_default.css | 12 | ||||
-rw-r--r-- | 97suifangqa/apps/indicator/static/javascripts/card_chart.js | 58 | ||||
-rw-r--r-- | 97suifangqa/apps/indicator/static/javascripts/edit_history_data.js | 50 | ||||
-rw-r--r-- | 97suifangqa/apps/indicator/static/javascripts/sheet_default.js | 30 | ||||
-rw-r--r-- | 97suifangqa/apps/indicator/templates/indicator/SheetDefault.html | 253 | ||||
-rw-r--r-- | 97suifangqa/apps/indicator/templates/indicator/popup/EditHistoryData.html | 1 | ||||
-rw-r--r-- | 97suifangqa/apps/indicator/urls.py | 4 | ||||
-rw-r--r-- | 97suifangqa/apps/indicator/views.py | 30 | ||||
-rw-r--r-- | 97suifangqa/isuifangqa.db | bin | 399360 -> 400384 bytes |
11 files changed, 309 insertions, 166 deletions
diff --git a/97suifangqa/apps/indicator/models.py b/97suifangqa/apps/indicator/models.py index 78860ce..4d95db0 100644 --- a/97suifangqa/apps/indicator/models.py +++ b/97suifangqa/apps/indicator/models.py @@ -320,6 +320,20 @@ class IndicatorRecord(models.Model): # {{{ #raise ValueError(u'date="%s" 该日期已经存在记录' % self.date) print u'date="%s" 该日期已经存在记录' % self.date return False + # check unit + sind = self.indicator + if sind.dataType in [sind.FLOAT_TYPE, sind.RANGE_TYPE, + sind.FLOAT_RANGE_TYPE]: + # unit required + ind_units = sind.get_unit(type="all") + if not self.unit: + #raise ValueError(u'未填写单位') + print u'未填写单位' + return False + elif self.unit not in ind_units: + #raise ValueError(u'所选单位与该指标不符') + print u'所选单位与该指标不符' + return False # check dataType if self.indicator.dataType == self.indicator.INTEGER_TYPE: # 整数型 @@ -332,10 +346,6 @@ class IndicatorRecord(models.Model): # {{{ return False elif self.indicator.dataType == self.indicator.FLOAT_TYPE: # 浮点型 - if not self.unit: - #raise ValueError(u'未填写单位') - print u'未填写单位' - return False try: value = float(self.value) return True @@ -345,10 +355,6 @@ class IndicatorRecord(models.Model): # {{{ return False elif self.indicator.dataType == self.indicator.RANGE_TYPE: # 范围型 - if not self.unit: - #raise ValueError(u'未填写单位') - print u'未填写单位' - return False if (self.val_max is None) or (self.val_min is None): #raise ValueError(u'val_max 或 val_min 未填写') print u'val_max 或 val_min 未填写' @@ -360,10 +366,6 @@ class IndicatorRecord(models.Model): # {{{ return True elif self.indicator.dataType == self.indicator.FLOAT_RANGE_TYPE: # 定值/范围型 (浮点定值优先) - if not self.unit: - #raise ValueError(u'未填写单位') - print u'未填写单位' - return False if self.value: # 定值 try: diff --git a/97suifangqa/apps/indicator/static/css/edit_history_data.css b/97suifangqa/apps/indicator/static/css/edit_history_data.css index 0209ca7..e1caa9f 100644 --- a/97suifangqa/apps/indicator/static/css/edit_history_data.css +++ b/97suifangqa/apps/indicator/static/css/edit_history_data.css @@ -94,12 +94,23 @@ input[type="radio"]:checked + label { } .edit_history_data_content .edit_data .state .normal { background-color: #B8DB70; + padding: 2px; } .edit_history_data_content .edit_data .state .abnormal { background-color: #FFB3B3; + padding: 2px; } .edit_history_data_content .edit_data .state .unknown { background-color: #B3D9FF; + padding: 2px; +} +.edit_history_data_content .edit_data #delete_btn { + float: right; + height: 26px; + line-height: 22px; + padding: 1px 26px; + margin-right: 8px; + background-color: #E64848; } .edit_history_data_content .edit_data #edit_btn, .edit_history_data_content .editing_data #save_btn { float: right; diff --git a/97suifangqa/apps/indicator/static/css/sheet_default.css b/97suifangqa/apps/indicator/static/css/sheet_default.css index b83dd6a..82d8fbb 100644 --- a/97suifangqa/apps/indicator/static/css/sheet_default.css +++ b/97suifangqa/apps/indicator/static/css/sheet_default.css @@ -249,6 +249,18 @@ input[type="radio"]:checked + label { height: 29px; color: #FFFFFF; } +.detail_card_info .table_div table .state .normal { + background-color: #B8DB70; + padding: 2px; +} +.detail_card_info .table_div table .state .abnormal { + background-color: #FFB3B3; + padding: 2px; +} +.detail_card_info .table_div table .state .unknown { + background-color: #B3D9FF; + padding: 2px; +} .detail_card_info .see_more { margin-top: 5px; } diff --git a/97suifangqa/apps/indicator/static/javascripts/card_chart.js b/97suifangqa/apps/indicator/static/javascripts/card_chart.js index 75cbf78..92a91c0 100644 --- a/97suifangqa/apps/indicator/static/javascripts/card_chart.js +++ b/97suifangqa/apps/indicator/static/javascripts/card_chart.js @@ -129,7 +129,7 @@ $(document).ready(function(){ //console.log(event); //console.log(this); var date = moment(this.x).utc().format('YYYY-MM-DD'); - TB_show(false, indicator_url+'popup/edithistorydata?card_id='+detail_card_id+'&date='+date+'&no_title=true&TB_iframe=true&height=351&width=630', false); + TB_show(false, indicator_url+'popup/edithistorydata?card_id='+detail_card_id+'&date='+date+'&no_title=true&TB_iframe=true&height=360&width=632', false); } } } @@ -138,9 +138,9 @@ $(document).ready(function(){ var getdata_type = "num"; var getdata_num = 10; detail_chart_getdata_draw(detail_chart_str, - detail_chart_options_str, - getdata_type, getdata_num, - begin_date_str, end_date_str + detail_chart_options_str, + getdata_type, getdata_num, + begin_date_str, end_date_str ); $(".act_card_container").addClass("move_div_2_left"); return false; @@ -152,17 +152,14 @@ $(document).ready(function(){ $(this).removeClass("unselected"); var begin_str = $(this).attr("begin_date"); var end_date = $(this).attr("end_date"); - // add 2 days to 'end_str' - // otherwise xAxis maybe incomplete to show the last data point var end_mm = moment(end_date); - end_mm.add('days', 2); var end_str = end_mm.format('YYYY-MM-DD'); var getdata_type = "date"; var getdata_num = null; detail_chart_getdata_draw(detail_chart_str, - detail_chart_options_str, - getdata_type, getdata_num, - begin_str, end_str + detail_chart_options_str, + getdata_type, getdata_num, + begin_str, end_str ); return false; }); @@ -172,17 +169,14 @@ $(document).ready(function(){ $(".shift_date").addClass("unselected"); var begin_str = $("#search_begin_date").val(); var end_date = $("#search_end_date").val(); - // add 2 days to 'end_str' - // otherwise xAxis maybe incomplete to show the last data point var end_mm = moment(end_date); - end_mm.add('days', 2); var end_str = end_mm.format('YYYY-MM-DD'); var getdata_type = "date"; var getdata_num = null; detail_chart_getdata_draw(detail_chart_str, - detail_chart_options_str, - getdata_type, getdata_num, - begin_str, end_str + detail_chart_options_str, + getdata_type, getdata_num, + begin_str, end_str ); return false; }); @@ -226,6 +220,7 @@ $(document).ready(function(){ }); }); +// detail_chart_getdata_draw {{{ // destroy the original chart and new. // chart_str: (string), // name of global var of chart to draw; @@ -256,27 +251,34 @@ function detail_chart_getdata_draw(chart_str, options_str, type, num, begin, end //console.log(dataJson); if (dataJson.failed || dataJson.number_rsp == 0) { // getdata failed or get no data + // XXX: tooltip?? return false; } else { var begin_dt = moment(dataJson.begin_rsp); var end_dt = moment(dataJson.end_rsp); + var begin_dt_axis = begin_dt.clone(); + var end_dt_axis = end_dt.clone(); if (dataJson.number_rsp == 1) { // only one data point // (3days) dp_date (4days) - begin_dt.subtract('days', 3); - end_dt.add('days', 4); + begin_dt_axis.subtract('days', 3); + end_dt_axis.add('days', 4); } else { var diff_days = end_dt.diff(begin_dt, 'days'); var days_toadd = Math.floor(diff_days*0.10) + 1; - end_dt.add('days', days_toadd); + end_dt_axis.add('days', days_toadd); } // type == "date" if (type == "date") { // use date of request instead begin_dt = moment(dataJson.begin_req); end_dt = moment(dataJson.end_req); + // add 2 days to 'end_dt' + // otherwise xAxis maybe incomplete + // to show the last data point + end_dt_axis = end_dt.clone().add('days', 2); } // update datepicker @@ -291,8 +293,8 @@ function detail_chart_getdata_draw(chart_str, options_str, type, num, begin, end // set chart data window[options_str].chart.renderTo = chart_str; - window[options_str].xAxis.min = begin_dt.valueOf(); - window[options_str].xAxis.max = end_dt.valueOf(); + window[options_str].xAxis.min = begin_dt_axis.valueOf(); + window[options_str].xAxis.max = end_dt_axis.valueOf(); window[options_str].series[0].data = dataJson.data; // destroy original chart and // redraw with new options and data @@ -305,11 +307,12 @@ function detail_chart_getdata_draw(chart_str, options_str, type, num, begin, end } }); } +// }}} -// get data for detail card table +// get data for detail card table {{{ // if append=true, then keep original data, // otherwise, replace original data with new data -function get_card_data_table(type, num, begin, end, append){ +function get_card_data_table(type, num, begin, end, append) { var type2 = type || "num"; // default get data by 'num' var num2 = num || ""; var begin2 = begin || ""; @@ -343,13 +346,13 @@ function get_card_data_table(type, num, begin, end, append){ } var record_html = r.value_html + unit_str; if (r.is_normal == true) { - var state = '正常'; + var state = '<span class="normal">正常</span>'; } else if (r.is_normal == false) { - var state = '不正常'; + var state = '<span class="abnormal">不正常</span>'; } else { - var state = '未知'; + var state = '<span class="unknwon">未知</span>'; } // tr_html var tr_html = '<tr id="record_' + r.id + '">'; @@ -357,7 +360,7 @@ function get_card_data_table(type, num, begin, end, append){ tr_html += '<td class="record">' + record_html + '</td>'; tr_html += '<td class="state">' + state + '</td>'; tr_html += '</tr>'; - //console.log('tr_html: ', tr_html); + //console.log('tr_html: '+tr_html); data_html += tr_html + '\n'; } // update table @@ -377,5 +380,6 @@ function get_card_data_table(type, num, begin, end, append){ } }); } +// }}} // vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=javascript: // diff --git a/97suifangqa/apps/indicator/static/javascripts/edit_history_data.js b/97suifangqa/apps/indicator/static/javascripts/edit_history_data.js index b85bced..d4ccdf5 100644 --- a/97suifangqa/apps/indicator/static/javascripts/edit_history_data.js +++ b/97suifangqa/apps/indicator/static/javascripts/edit_history_data.js @@ -21,6 +21,37 @@ $(document).ready(function(){ maxDate: 0 // 0->today, 1->tomorrow }); + // delete button + $("#delete_btn").bind("click", function(){ + // delete record (ajax) + var time = moment().valueOf(); + $.ajax({ + type: 'get', + url: indicator_url + 'ajax/delete_record/', + data: 'record_id='+record_id + '&time='+time, + success: function(data) { + if (data == 'success') { + // redraw chart + var begin_str = $("#search_begin_date", window.parent.document).val(); + var end_str = $("#search_end_date", window.parent.document).val(); + //console.log("begin_str: "+begin_str); + //console.log("end_str: "+end_str); + var getdata_type = "date"; + var getdata_num = null; + parent.detail_chart_getdata_draw( + parent.detail_chart_str, + parent.detail_chart_options_str, + getdata_type, getdata_num, + begin_str, end_str + ); + // close popup window + parent.TB_remove(); + } + } + }); + return false; + }); + // edit button $("#edit_btn").bind("click", function(){ var this_edit_data_div = $(this).closest(".edit_data"); @@ -63,10 +94,25 @@ $(document).ready(function(){ // tooltip } else { + // redraw chart + var begin_str = $("#search_begin_date", window.parent.document).val(); + var end_str = $("#search_end_date", window.parent.document).val(); + var end_mm = moment(end_str); + var record_date_mm = moment(record_data.date); + if (record_date_mm.isAfter(end_mm)) { + end_str = record_date_mm.format('YYYY-MM-DD'); + } + // + var getdata_type = "date"; + var getdata_num = null; + parent.detail_chart_getdata_draw( + parent.detail_chart_str, + parent.detail_chart_options_str, + getdata_type, getdata_num, + begin_str, end_str + ); // successfully modified parent.TB_remove(); - // update the detail chart - //parent.redraw_chart(parent.detail_chart, "2013-08-04", "2013-08-10"); //这边需要穿过来起始,结束时间,以便刷新图表和表格 } } }); diff --git a/97suifangqa/apps/indicator/static/javascripts/sheet_default.js b/97suifangqa/apps/indicator/static/javascripts/sheet_default.js index e5d9e9e..4d1683a 100644 --- a/97suifangqa/apps/indicator/static/javascripts/sheet_default.js +++ b/97suifangqa/apps/indicator/static/javascripts/sheet_default.js @@ -70,7 +70,7 @@ $(document).ready(function(){ var time = date.getTime(); $.ajax({ //数据库还是cookie,都可以,建议使用cookie,html中是否显示sub_title也由后端读取的cookie决定 type: 'get', - url: indicator_url + 'ajax/close_sub_title', + url: indicator_url + 'ajax/close_sub_title/', data: 'time='+time, success: function(data){ if(data == 'success'){ @@ -419,7 +419,7 @@ $(document).ready(function(){ }); // }}} - //点击提交icon + //点击提交icon {{{ $(".confirm_edit_icon").bind("click", function(){ var this_editing_data_div = $(this).closest(".editing_data"); var card = $(this).closest(".index_card"); @@ -488,8 +488,13 @@ $(document).ready(function(){ // refresh_icon this_edit_data_div.find(".refresh_icon").show(); // edit_icon_container & chart - this_editing_data_div.siblings(".edit_icon_container").hide(); - this_editing_data_div.siblings(".chart").show(); + toggle_edit_hint(id, "hide"); + // redraw chart + chart_getdata_draw("chart_"+id, id, + "options_chart_"+id, + chart_getdata_type, chart_dp_num, + null, null + ); } } }); @@ -497,6 +502,7 @@ $(document).ready(function(){ return false; }); + // }}} //日期控件 $(".datepicker_container>.datepicker").datepicker({ @@ -526,6 +532,22 @@ $(document).ready(function(){ }); }); +// toggle 'edit_hint' +function toggle_edit_hint(card_id, action) { + var card = $("#index_card_"+card_id); + var edit_hint = card.find(".edit_icon_container"); + var chart = card.find(".chart"); + if (action === 'show') { + chart.hide(); + edit_hint.show(); + } + else if (action === 'hide') { + edit_hint.hide(); + chart.show(); + } + return false; +} + // function delete_card(){ var card = $("#index_card_"+card_2_delete_id); diff --git a/97suifangqa/apps/indicator/templates/indicator/SheetDefault.html b/97suifangqa/apps/indicator/templates/indicator/SheetDefault.html index 653fde3..07cf2f0 100644 --- a/97suifangqa/apps/indicator/templates/indicator/SheetDefault.html +++ b/97suifangqa/apps/indicator/templates/indicator/SheetDefault.html @@ -109,10 +109,15 @@ dataType: 'json', success: function (dataJson) { //console.log(dataJson); - if (dataJson.failed || dataJson.number_rsp == 0) { + if (dataJson.failed) { // getdata failed or get no data + // XXX: tooltip return false; } + else if (dataJson.number_rsp == 0) { + // show 'edit_hint' + toggle_edit_hint(card_id, "show"); + } else { var begin_dt = moment(dataJson.begin_rsp); var end_dt = moment(dataJson.end_rsp); @@ -132,7 +137,13 @@ window[options_str].xAxis.max = end_dt.valueOf(); window[options_str].series[0].data = dataJson.data; // draw the chart - // given 'chart_str' is the global var name of this chart + // 'chart_str' is the global var name of this chart + // destroy original chart and + // redraw with new options and data + if (window[chart_str] != null) { + window[chart_str].destroy(); + window[chart_str] = null; + } window[chart_str] = new Highcharts.Chart(window[options_str]); } }, @@ -140,134 +151,132 @@ } // }}} {% for ind in indicators %} - {% if not ind|dict_get:"record_empty" %} {# indicator has records #} - {% if ind|dict_get:"dataType" == DATA_TYPES|dict_get:"INTEGER_TYPE" %} - {# INTEGER_TYPE #} - {# TODO #} - {% elif ind|dict_get:"dataType" == DATA_TYPES|dict_get:"FLOAT_TYPE" %} - {# FLOAT_TYPE #} - var chart_{{ ind|dict_get:"id" }}; - // global var name style: 'options_chart_<id>' - // keep the name style, used in 'detail_history' binded functions - var options_chart_{{ ind|dict_get:"id" }} = { // {{{ - chart: { - type: 'areaspline', - renderTo: 'chart_{{ ind|dict_get:"id" }}' - }, + {% if ind|dict_get:"dataType" == DATA_TYPES|dict_get:"INTEGER_TYPE" %} + {# INTEGER_TYPE #} + {# TODO #} + {% elif ind|dict_get:"dataType" == DATA_TYPES|dict_get:"FLOAT_TYPE" %} + {# FLOAT_TYPE #} + var chart_{{ ind|dict_get:"id" }}; + // global var name style: 'options_chart_<id>' + // keep the name style, used in 'detail_history' binded functions + var options_chart_{{ ind|dict_get:"id" }} = { // {{{ + chart: { + type: 'areaspline', + renderTo: 'chart_{{ ind|dict_get:"id" }}' + }, + labels: { + items: [{ // custom label for unit_symbol + html: '{{ ind|dict_get:"std_unit_symbol" }}', + style: { + left: '5px', + top: '0px' + } + }] + }, + series: [{ + data: [] + }], + tooltip: { + formatter: function() { + return '<span style="color:#969696;font-weight:bold;">' + Highcharts.dateFormat('%Y-%m-%d', this.x) + '</span>' +'<br />' + '<span style="color:#464646;font-weight:bold;">' + this.y + ' ({{ ind|dict_get:"std_unit_symbol" }})' + '</span>'; + } + }, + xAxis: { + min: null, + max: null + }, + yAxis: { labels: { - items: [{ // custom label for unit_symbol - html: '{{ ind|dict_get:"std_unit_symbol" }}', - style: { - left: '5px', - top: '0px' - } - }] - }, - series: [{ - data: [] - }], - tooltip: { + useHTML: true, formatter: function() { - return '<span style="color:#969696;font-weight:bold;">' + Highcharts.dateFormat('%Y-%m-%d', this.x) + '</span>' +'<br />' + '<span style="color:#464646;font-weight:bold;">' + this.y + ' ({{ ind|dict_get:"std_unit_symbol" }})' + '</span>'; - } - }, - xAxis: { - min: null, - max: null - }, - yAxis: { - labels: { - useHTML: true, - formatter: function() { - var value = this.value; - if (value > 9999.0) { - var value_str = value.toExponential(2); - var m = exp_regex.exec(value_str); - var ylabel = m[1] + m[2].replace(/(\.0*|0*)$/, '') + '×10<sup>' + m[3]+m[4] + '</sup>'; - } - else { - var ylabel = value.toString(); - } - return ylabel; + var value = this.value; + if (value > 9999.0) { + var value_str = value.toExponential(2); + var m = exp_regex.exec(value_str); + var ylabel = m[1] + m[2].replace(/(\.0*|0*)$/, '') + '×10<sup>' + m[3]+m[4] + '</sup>'; } + else { + var ylabel = value.toString(); + } + return ylabel; } } - }; // }}} - // draw chart - $(document).ready(function() { - chart_getdata_draw("chart_{{ ind|dict_get:"id" }}", - {{ ind|dict_get:"id" }}, - "options_chart_{{ ind|dict_get:"id" }}", - chart_getdata_type, chart_dp_num, - null, null - ); - }); - {% elif ind|dict_get:"dataType" == DATA_TYPES|dict_get:"RANGE_TYPE" %} - {# RANGE_TYPE #} - var chart_{{ ind|dict_get:"id" }}; - var options_chart_{{ ind|dict_get:"id" }} = { // {{{ - chart: { - type: 'areasplinerange', - renderTo: 'chart_{{ ind|dict_get:"id" }}' - }, + } + }; // }}} + // draw chart + $(document).ready(function() { + chart_getdata_draw("chart_{{ ind|dict_get:"id" }}", + {{ ind|dict_get:"id" }}, + "options_chart_{{ ind|dict_get:"id" }}", + chart_getdata_type, chart_dp_num, + null, null + ); + }); + {% elif ind|dict_get:"dataType" == DATA_TYPES|dict_get:"RANGE_TYPE" %} + {# RANGE_TYPE #} + var chart_{{ ind|dict_get:"id" }}; + var options_chart_{{ ind|dict_get:"id" }} = { // {{{ + chart: { + type: 'areasplinerange', + renderTo: 'chart_{{ ind|dict_get:"id" }}' + }, + labels: { + items: [{ // custom label for unit_symbol + html: '{{ ind|dict_get:"std_unit_symbol" }}', + style: { + left: '5px', + top: '0px' + } + }] + }, + series: [{ + data: [] + }], + tooltip: { + formatter: function() { + return '<span style="color:#969696;font-weight:bold;">' + Highcharts.dateFormat('%Y-%m-%d', this.x) + '</span>' + '<br />' + '<span style="color:#464646;font-weight:bold;">' + this.point.low + ' ∼ ' + this.point.high + ' ({{ ind|dict_get:"std_unit_symbol" }})' + '</span>'; + } + }, + xAxis: { + min: null, + max: null + }, + yAxis: { labels: { - items: [{ // custom label for unit_symbol - html: '{{ ind|dict_get:"std_unit_symbol" }}', - style: { - left: '5px', - top: '0px' - } - }] - }, - series: [{ - data: [] - }], - tooltip: { + useHTML: true, formatter: function() { - return '<span style="color:#969696;font-weight:bold;">' + Highcharts.dateFormat('%Y-%m-%d', this.x) + '</span>' + '<br />' + '<span style="color:#464646;font-weight:bold;">' + this.point.low + ' ∼ ' + this.point.high + ' ({{ ind|dict_get:"std_unit_symbol" }})' + '</span>'; - } - }, - xAxis: { - min: null, - max: null - }, - yAxis: { - labels: { - useHTML: true, - formatter: function() { - var value = this.value; - if (value > 9999.0) { - var value_str = value.toExponential(2); - var m = exp_regex.exec(value_str); - var ylabel = m[1] + m[2].replace(/(\.0*|0*)$/, '') + '×10<sup>' + m[3]+m[4] + '</sup>'; - } - else { - var ylabel = value.toString(); - } - return ylabel; + var value = this.value; + if (value > 9999.0) { + var value_str = value.toExponential(2); + var m = exp_regex.exec(value_str); + var ylabel = m[1] + m[2].replace(/(\.0*|0*)$/, '') + '×10<sup>' + m[3]+m[4] + '</sup>'; + } + else { + var ylabel = value.toString(); } + return ylabel; } } - }; // }}} - // draw chart - $(document).ready(function() { - chart_getdata_draw("chart_{{ ind|dict_get:"id" }}", - {{ ind|dict_get:"id" }}, - "options_chart_{{ ind|dict_get:"id" }}", - chart_getdata_type, chart_dp_num, - null, null - ); - }); - {% elif ind|dict_get:"dataType" == DATA_TYPES|dict_get:"FLOAT_RANGE_TYPE" %} - {# FLOAT_RANGE_TYPE #} - {# TODO #} - {% elif ind|dict_get:"dataType" == DATA_TYPES|dict_get:"PM_TYPE" %} - {# PM_TYPE #} - {# TODO #} - {% else %} - {# unknown TYPE #} - {% endif %} {# end: DATA_TYPES #} - {% endif %} {# end: record_empty #} + } + }; // }}} + // draw chart + $(document).ready(function() { + chart_getdata_draw("chart_{{ ind|dict_get:"id" }}", + {{ ind|dict_get:"id" }}, + "options_chart_{{ ind|dict_get:"id" }}", + chart_getdata_type, chart_dp_num, + null, null + ); + }); + {% elif ind|dict_get:"dataType" == DATA_TYPES|dict_get:"FLOAT_RANGE_TYPE" %} + {# FLOAT_RANGE_TYPE #} + {# TODO #} + {% elif ind|dict_get:"dataType" == DATA_TYPES|dict_get:"PM_TYPE" %} + {# PM_TYPE #} + {# TODO #} + {% else %} + {# unknown TYPE #} + {% endif %} {# end: DATA_TYPES #} {% endfor %} </script> {% endblock %} @@ -355,11 +364,13 @@ <span class="date_value">{{ ind|dict_get:"last_record"|dict_get:"date" }}</span> </div> <!-- refresh icon --> + {% comment %} {% if ind|dict_get:"record_empty" %} <div class="refresh_icon" style="display: none;"></div> {% else %} <div class="refresh_icon" style="display: block;"></div> {% endif %} + {% endcomment %} <div style="clear:both;"></div> </div> <!-- end: edit_data --> @@ -469,7 +480,7 @@ <tr class="first_line"> <td class="date" width="124px">化验日期</td> <td class="record" width="312px">数据记录</td> - <td class="state" width="122px">是否正常</td> + <td class="state" width="122px">状态</td> </tr> </table> </div> diff --git a/97suifangqa/apps/indicator/templates/indicator/popup/EditHistoryData.html b/97suifangqa/apps/indicator/templates/indicator/popup/EditHistoryData.html index 7c530ea..efe8588 100644 --- a/97suifangqa/apps/indicator/templates/indicator/popup/EditHistoryData.html +++ b/97suifangqa/apps/indicator/templates/indicator/popup/EditHistoryData.html @@ -90,6 +90,7 @@ {% endif %} </div> <input type="button" id="edit_btn" value="修改记录" /> + <input type="button" id="delete_btn" value="删除记录" /> </div> <div class="editing_data"> {% csrf_token %} diff --git a/97suifangqa/apps/indicator/urls.py b/97suifangqa/apps/indicator/urls.py index cd53b39..fe0fcdb 100644 --- a/97suifangqa/apps/indicator/urls.py +++ b/97suifangqa/apps/indicator/urls.py @@ -86,6 +86,10 @@ urlpatterns += patterns('indicator.views', url(r'^ajax/close_sub_title/$', 'ajax_close_sub_title', name='indicator_ajax_closesubtitle'), + # delete_record + url(r'^ajax/delete_record/$', + 'ajax_delete_record', + name='indicator_ajax_deleterecord'), # get_card_data_chart url(r'^ajax/get_card_data_chart/$', 'ajax_get_card_data_chart', diff --git a/97suifangqa/apps/indicator/views.py b/97suifangqa/apps/indicator/views.py index 8d46537..d317277 100644 --- a/97suifangqa/apps/indicator/views.py +++ b/97suifangqa/apps/indicator/views.py @@ -1174,6 +1174,35 @@ def ajax_close_sub_title(request): # }}} +# ajax_delete_record {{{ +@login_required +def ajax_delete_record(request): + """ + delete the specified record + """ + result = 'failed' + if request.is_ajax() and request.method == 'GET': + record_id = request.GET.get('record_id') + # get record object + try: + record_id = int(record_id) + record_obj = get_object_or_404(im.IndicatorRecord, + id=record_id) + record_obj.delete() + result = 'success' + except ValueError: + print u'Error: record_id="%s" cannot convert to integer'\ + % record_id + result = 'failed' + except: + print u'Error: unknwon error' + result = 'failed' + + # + return HttpResponse(result) +# }}} + + # ajax_get_card_data_chart {{{ @login_required def ajax_get_card_data_chart(request): @@ -1538,6 +1567,7 @@ def ajax_search_indicators(request): return HttpResponse(json.dumps(data), mimetype='application/json') # }}} + # ajax_unfollow_indicator {{{ @login_required def ajax_unfollow_indicator(request): diff --git a/97suifangqa/isuifangqa.db b/97suifangqa/isuifangqa.db Binary files differindex 6d37e50..72b3b02 100644 --- a/97suifangqa/isuifangqa.db +++ b/97suifangqa/isuifangqa.db |