medical.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. new Vue({
  2. el: '#app',
  3. data: {
  4. city: '上饶市',
  5. town: [],
  6. cityVal:"0",
  7. timeType: '1', //时间过滤条件 1是上月 2是半年
  8. leftData: {}, //左边数据块
  9. leftData1: {}, //左边数据块1
  10. leftData2: {}, //左边数据块2
  11. yesterdayData: {},
  12. leftChart1: null, //左边的图表1
  13. leftChart2: null, //左边的图表2
  14. rightChart1: null, //右边边的图表1
  15. rightChart2: null, //右边的图表2
  16. tableData1: null, //表格数据1
  17. tableData2: null, //表格数据2
  18. mapData: null,
  19. allData: null, //所有的数据 用来切换区县
  20. lineHeightIndex: null,
  21. skipShow: 0,
  22. hasData1:true,
  23. hasData2:true,
  24. hasData3:true,
  25. hasData4:true,
  26. hasData5:true,
  27. hasData6:true,
  28. },
  29. mounted: function() {
  30. this.initData();
  31. },
  32. methods: {
  33. initData: function() {
  34. $(".div-mask-layer").show();
  35. var vm = this,data1, data2, data3, data4, data5, data6, data7, data8;
  36. this.town.map(function(v, i) {
  37. if(v.name == vm.city) {
  38. vm.cityVal = v.id;
  39. }
  40. })
  41. var linkageFilter1 = "quotaDate >= '" + getLastMonthStartDate() + "' and quotaDate <= '" + getLastMonthEndDate() + "';";
  42. if(vm.cityVal!="0") {
  43. linkageFilter1 += "town=" + vm.cityVal + ";";
  44. }
  45. var linkageFilter2 = "quotaDate >= '" + getYearStartDate() + "' and quotaDate <= '" + getYearEndDate() + "';";
  46. if(vm.cityVal!="0") {
  47. linkageFilter2 += "town=" + vm.cityVal + ";";
  48. }
  49. var linkageFilter3 = "quotaDate >= '" + getHalfYearStartDate() + "' and quotaDate <= '" + getHalfYearEndDate() + "';";
  50. if(vm.cityVal!="0") {
  51. linkageFilter3 += "town=" + vm.cityVal + ";";
  52. }
  53. var linkageFilter4 = "quotaDate >= '" + getYearEndDate() + "' and quotaDate <= '" + getYearEndDate() + "';";
  54. if(vm.cityVal!="0") {
  55. linkageFilter4 += "town=" + vm.cityVal + ";";
  56. }
  57. var reqUrl = [{url: bigDataAPI.getCityArea,reqType: 'get',data: {}},
  58. {url: bigDataAPI.getNoChartTemplateData,reqType: 'get',data: {viewCodeStr: "VIEW_14_0011",linkageFilter:linkageFilter1}},//左上角-上月
  59. {url: bigDataAPI.getNoChartTemplateData,reqType: 'get',data: {viewCodeStr: "VIEW_14_0011",linkageFilter:linkageFilter2}},//左上角-本年
  60. {url: bigDataAPI.getNoChartTemplateData,reqType: 'get',data: {viewCodeStr: "VIEW_14_0012",linkageFilter:linkageFilter4}},
  61. {url: bigDataAPI.getNoChartTemplateData,reqType: 'get',data: {viewCodeStr: "VIEW_14_0013",linkageFilter:linkageFilter3}},//
  62. {url: bigDataAPI.getNoChartTemplateData,reqType: 'get',data: {viewCodeStr: "VIEW_14_0014",linkageFilter:linkageFilter3}},//
  63. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: "VIEW_14_0015",linkageFilter:linkageFilter3}},//门诊人次月趋势
  64. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: "VIEW_14_0016",linkageFilter:linkageFilter3}},//住院人次月趋势
  65. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: "VIEW_14_0017",linkageFilter:linkageFilter3}},//门诊分类别月趋势
  66. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: "VIEW_14_0018",linkageFilter:linkageFilter3}},//住院平均日数月趋势
  67. {url:bigDataAPI.getMapJingWeiDuInfo,reqType: 'get',data:{}},//上饶地图经纬度数据
  68. ];
  69. httpRequest.getReqPromises(reqUrl).then(function(datas) {
  70. vm.town = [{
  71. "name": "上饶市",
  72. "id": "0"
  73. }].concat(datas[0]);
  74. vm.leftData1 = datas[1];
  75. vm.leftData2 = datas[2];
  76. data3 = datas[3];
  77. data4 = datas[4];
  78. data5 = datas[5];
  79. data6 = datas[6];
  80. data7 = datas[7];
  81. data8 = datas[8];
  82. data9 = datas[9];
  83. data10 = datas[10];
  84. vm.setLeftChart1(data6);
  85. vm.setLeftChart2(data7);
  86. vm.setRightChart1(data8);
  87. vm.setRightChart2(data9);
  88. vm.setTable1(data4);
  89. vm.setTable2(data5);
  90. vm.setleftData1();
  91. echarts.registerMap('上饶',data10);
  92. vm.setMapData(data3);
  93. vm.setYesterDay(data3);
  94. $(".div-mask-layer").hide();
  95. })
  96. },
  97. setleftData1: function() {
  98. var options = null,vm=this;
  99. if(this.timeType == 1) {
  100. if(this.leftData1.successFlg) {
  101. _.map(vm.leftData1.obj.VIEW_14_0011,function(item,index){
  102. if(vm.cityVal=="0"){//上饶市
  103. options = vm.leftData1.obj.VIEW_14_0011[0];
  104. }else if(item.firstColumn==vm.city){
  105. options = item;
  106. }
  107. })
  108. }
  109. } else {
  110. if(this.leftData2.successFlg) {
  111. _.map(vm.leftData2.obj.VIEW_14_0011,function(item,index){
  112. if(vm.cityVal=="0"){//上饶市
  113. options = vm.leftData2.obj.VIEW_14_0011[0];
  114. }else if(item.firstColumn==vm.city){
  115. options = item;
  116. }
  117. })
  118. }
  119. }
  120. this.setFormater(options);
  121. this.leftData = options;
  122. },
  123. setYesterDay: function(data3) {
  124. var options = null,vm=this;
  125. if(data3.successFlg) {
  126. _.map(data3.obj.VIEW_14_0012,function(item,index){
  127. if(vm.cityVal=="0"){//上饶市
  128. options = data3.obj.VIEW_14_0012[0];
  129. }else if(item.firstColumn==vm.city){
  130. options = item;
  131. }
  132. })
  133. }
  134. this.setFormater(options);
  135. this.yesterdayData = options;
  136. },
  137. setLeftChart1: function(data6) {
  138. var options = null;
  139. var options = data6.successFlg?data6.obj.viewInfos&&JSON.parse(data6.obj.viewInfos[0].options[0].option):{};
  140. if(options&&options.series && options.series[0].data && options.series[1].data){
  141. options = leftChart1DataFormat(options);
  142. this.leftChart1 = options;
  143. this.hasData1 = true;
  144. }else{
  145. this.hasData1 = false;
  146. }
  147. },
  148. setLeftChart2: function(data7) {
  149. var options = null;
  150. var options = data7.successFlg?data7.obj.viewInfos&&JSON.parse(data7.obj.viewInfos[0].options[0].option):{};
  151. if(options&&options.series && options.series[0].data && options.series[1].data){
  152. options = leftChart2DataFormat(options);
  153. this.leftChart2 = options;
  154. this.hasData2 = true;
  155. }else{
  156. this.hasData2 = false;
  157. }
  158. },
  159. setMapData: function(data3) {
  160. var optionData = [];
  161. _.map(data3.obj.VIEW_14_0012, function(item) {
  162. if(item.firstColumn != "合计") {
  163. optionData.push({
  164. name: item.townName,
  165. value: parseInt(item.HC_14_1019)
  166. })
  167. }
  168. })
  169. var options = optionData;
  170. this.mapData = {
  171. data: options,
  172. index: this.lineHeightIndex
  173. };
  174. },
  175. setRightChart1: function(data8) {
  176. debugger
  177. var options = null;
  178. var options = data8.successFlg?data8.obj.viewInfos&&JSON.parse(data8.obj.viewInfos[0].options[0].option):{};
  179. if(options&&options.series && options.series[0].data && options.series[1].data && options.series[2].data && options.series[3].data){
  180. options = rightChart1DataFormat(options);
  181. this.rightChart1 = options
  182. this.hasData4 = true;
  183. $(".right1 .contentBox3").removeClass("div-menzhenfenleibei");
  184. }else{
  185. this.hasData4 = false;
  186. $(".right1 .contentBox3").addClass("div-menzhenfenleibei");
  187. }
  188. },
  189. setRightChart2: function(data9) {
  190. var options = null;
  191. var options = data9.successFlg?data9.obj.viewInfos&&JSON.parse(data9.obj.viewInfos[0].options[0].option):{};
  192. if(options&&options.series && options.series[0].data && options.series[1].data){
  193. options = rightChart2DataFormat(options);
  194. this.rightChart2 = options
  195. this.hasData6 = true;
  196. $(".right2 .contentBox3").removeClass("div-menzhenfenleibei");
  197. }else{
  198. this.hasData6 = false;
  199. $(".right2 .contentBox3").addClass("div-menzhenfenleibei");
  200. }
  201. },
  202. setTable1: function(data4) {
  203. var resData = [];
  204. var data = data4.successFlg?data4.obj.VIEW_14_0013:[];
  205. _.map(data, function(item, index) {
  206. if(item.firstColumn != "合计" && item.month) {
  207. item.month = parseInt(item.month.substring(5, 7))+"月";
  208. resData.push(item)
  209. }
  210. })
  211. if(resData.length==0){
  212. this.hasData3 = false;
  213. }else{
  214. this.hasData3 = true;
  215. this.tableData1 = resData
  216. }
  217. },
  218. setTable2: function(data5) {
  219. var resData = [];
  220. var data = data5.successFlg?data5.obj.VIEW_14_0014:[];
  221. _.map(data, function(item, index) {
  222. if(item.firstColumn != "合计" && item.month) {
  223. item.month = parseInt(item.month.substring(5, 7))+"月";
  224. resData.push(item)
  225. }
  226. })
  227. if(resData.length==0){
  228. this.hasData5 = false;
  229. }else{
  230. this.hasData5 = true;
  231. this.tableData2 = resData
  232. }
  233. },
  234. setCity(item) {
  235. this.city = item.name;
  236. },
  237. setTimeStr(v) {
  238. this.timeType = v;
  239. this.setleftData1()
  240. },
  241. setFormater: function(obj) {
  242. for(var c in obj) {
  243. if(obj[c].indexOf(",") == -1){//不存在,,说明要格式化
  244. obj[c] = toThousands(obj[c])
  245. }
  246. }
  247. },
  248. formatDate2017: function() {
  249. //获取上个月第一天
  250. var firstdate = new Date(new Date().getFullYear()-1, new Date().getMonth() - 1, 1);
  251. //获取上个月最后一天
  252. var date = new Date();
  253. var day = new Date(date.getFullYear()-1, date.getMonth(), 0).getDate();
  254. var enddate = new Date(new Date().getFullYear()-1, new Date().getMonth() - 1, day);
  255. //获取本年第一天和最后一天
  256. var firstYearDate = new Date();
  257. firstYearDate.setFullYear(new Date().getFullYear()-1)
  258. firstYearDate.setDate(1);
  259. firstYearMonty = firstYearDate.setMonth(0);
  260. //近半年开始时间
  261. var date1 = new Date();
  262. date1.setMonth(date1.getMonth() - 6);
  263. var year1 = date1.getFullYear() - 1;
  264. var month1 = date1.getMonth() + 1;
  265. month1 = (month1 < 10 ? "0" + month1 : month1);
  266. //格式化结果
  267. this.firstDay = firstdate.format("yyyy-MM-dd");
  268. this.lastDay = enddate.format("yyyy-MM-dd");
  269. this.firstDayYear = firstYearDate.format("yyyy-MM-dd");
  270. this.lastDayYear = (new Date().getFullYear()-1) + "-12-31";
  271. this.halfYearStartDate = year1.toString() + '-' + month1.toString() + "-01";
  272. this.halfYearEndDate = this.getCurrentMonthLast2017();
  273. this.yesterdayDate = this.getYesterday2017(-1, '-');
  274. },
  275. getYesterday2017:function(num, str){
  276. var today = new Date();
  277. var nowTime = today.getTime();
  278. var ms = 24*3600*1000*num;
  279. today.setTime(parseInt(nowTime + ms));
  280. var oYear = today.getFullYear()-1;
  281. var oMoth = (today.getMonth() + 1).toString();
  282. if (oMoth.length <= 1) oMoth = '0' + oMoth;
  283. var oDay = today.getDate().toString();
  284. if (oDay.length <= 1) oDay = '0' + oDay;
  285. return oYear + str + oMoth + str + oDay;
  286. },
  287. getCurrentMonthLast2017: function() {
  288. var date = new Date();
  289. var currentMonth = date.getMonth();
  290. var nextMonth = ++currentMonth;
  291. var nextMonthFirstDay = new Date(date.getFullYear() - 1, nextMonth-1, 1);
  292. var oneDay = 1000 * 60 * 60 * 24;
  293. return(new Date(nextMonthFirstDay - oneDay)).format("yyyy-MM-dd");
  294. },
  295. newObj: function(obj) {
  296. return JSON.parse(JSON.stringify(obj))
  297. },
  298. clickMap: function(res) {
  299. this.city = res.name;
  300. },
  301. skipClick: function() {
  302. console.log(222)
  303. this.skipShow == 0 ? this.skipShow = 1 : this.skipShow = 0
  304. }
  305. },
  306. watch: {
  307. city: function(value) {
  308. var that = this;
  309. that.lineHeightIndex = value;
  310. this.initData();
  311. }
  312. }
  313. });
  314. //数字格式化
  315. function toThousands(str) {
  316. if(!str) return
  317. str = parseInt(str);
  318. if(typeof(str) == 'number') str = str.toString()
  319. var newStr = "";
  320. var count = 0;
  321. if(str.indexOf(".") == -1) {
  322. for(var i = str.length - 1; i >= 0; i--) {
  323. if(count % 3 == 0 && count != 0) {
  324. newStr = str.charAt(i) + "," + newStr;
  325. } else {
  326. newStr = str.charAt(i) + newStr;
  327. }
  328. count++;
  329. }
  330. str = newStr;
  331. } else {
  332. for(var i = str.indexOf(".") - 1; i >= 0; i--) {
  333. if(count % 3 == 0 && count != 0) {
  334. newStr = str.charAt(i) + "," + newStr;
  335. } else {
  336. newStr = str.charAt(i) + newStr; //逐个字符相接起来
  337. }
  338. count++;
  339. }
  340. str = newStr + (str + "00").substr((str + "00").indexOf("."), 3);
  341. }
  342. return str;
  343. }