123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- new Vue({
- el: '#app',
- data: {
- city:'贵港市',
- town: [
- {
- "townName": "港北区",
- "result": "26531"
- },
- {
- "townName": "港南区",
- "result": "25634"
- },
- {
- "townName": "覃塘区",
- "result": "12587"
- },
- {
- "townName": "平南县",
- "result": "74128"
- },
- {
- "townName": "桂平市",
- "result": "113485"
- }
- ],
- leftData1:{}, //左边数据块1
- leftData2:{}, //左边数据块2
- leftChart1:null, //左边的图表1
- leftChart2:null, //左边的图表2
- leftChart3:null, //左边的图表3
- timeType:'1'//时间过滤条件 1是上月 2是半年
- },
- mounted: function() {
- this.initData()
- },
- methods: {
- initData:function(){
- this.setLeftChart1();
- this.setLeftChart2();
- this.setleftData1();
- window.leftData1 = this.leftData1
- },
- setleftData1:function(){
- var options = null;
- if(this.timeType == 1){
- options= this.newObj(bigData['上月']);
-
- }
- else{
- options= this.newObj(bigData['本年'])
- }
- this.setFormater(options);
- this.leftData1 = options;
- },
- setLeftChart1:function(){
- var options =bigData['门诊人次月趋势'];
- this.leftChart1 = options
-
- },
- setLeftChart2:function(){
- var options =bigData['住院人次月趋势'];
- this.leftChart2 = options
- },
- setLeftChart3:function(){
- var options =bigData['门诊分类别月趋势'];
- this.leftChart3= options
- },
- setCity(item){
- this.city = item.townName
- },
- setTimeStr(v){
- this.timeType = v;
- this.setleftData1()
- },
- setFormater:function(obj){
- for(var c in obj){
- obj[c] =toThousands(obj[c])
- }
- },
- newObj:function(obj){
- return JSON.parse(JSON.stringify(obj))
- }
- }
- });
- //数字格式化
- function toThousands(str) {
- if(!str)return
- str =parseInt(str);
- if(typeof(str) == 'number')str = str.toString()
- var newStr = "";
- var count = 0;
- if(str.indexOf(".") == -1) {
- for(var i = str.length - 1; i >= 0; i--) {
- if(count % 3 == 0 && count != 0) {
- newStr = str.charAt(i) + "," + newStr;
- } else {
- newStr = str.charAt(i) + newStr;
- }
- count++;
- }
- str = newStr;
- } else {
- for(var i = str.indexOf(".") - 1; i >= 0; i--) {
- if(count % 3 == 0 && count != 0) {
- newStr = str.charAt(i) + "," + newStr;
- } else {
- newStr = str.charAt(i) + newStr; //逐个字符相接起来
- }
- count++;
- }
- str = newStr + (str + "00").substr((str + "00").indexOf("."), 3);
- }
- return str;
- }
|