medical.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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. bakLeftData1:{},//缓存左边数据块1
  12. bakLeftData2:{},//缓存左边数据块2
  13. yesterdayData: {},
  14. leftChart1: null, //左边的图表1
  15. leftChart2: null, //左边的图表2
  16. rightChart1: null, //右边边的图表1
  17. rightChart2: null, //右边的图表2
  18. tableData1: null, //表格数据1
  19. tableData2: null, //表格数据2
  20. mapData: null,
  21. allData: null, //所有的数据 用来切换区县
  22. lineHeightIndex: null,
  23. skipShow: 0,
  24. hasData1:true,
  25. hasData2:true,
  26. hasData3:true,
  27. hasData4:true,
  28. hasData5:true,
  29. hasData6:true,
  30. hasMapData:true,
  31. },
  32. mounted: function() {
  33. this.initData();
  34. },
  35. filters:{
  36. formatData:function(value){
  37. if(value>100000){
  38. if(value>1000000000){
  39. return (value/100000000).toFixed(2)+"亿"
  40. }else{
  41. return (value/10000).toFixed(2)+"万"
  42. }
  43. }else{
  44. return value
  45. }
  46. }
  47. },
  48. methods: {
  49. initData: function() {
  50. this.timeType = 1;//默认显示本月
  51. $(".div-mask-layer").show();
  52. var vm = this,data1, data2, data3, data4, data5, data6, data7, data8;
  53. this.town.map(function(v, i) {
  54. if(v.name == vm.city) {
  55. vm.cityVal = v.id;
  56. }
  57. })
  58. var linkageFilter1 = "quotaDate >= '" + getLastMonthStartDate() + "' and quotaDate <= '" + getLastMonthEndDate() + "';";
  59. if(vm.cityVal!="0") {
  60. linkageFilter1 += "town=" + vm.cityVal + ";";
  61. }
  62. var linkageFilter2 = "quotaDate >= '" + getYearStartDate() + "' and quotaDate <= '" + getYearEndDate() + "';";
  63. if(vm.cityVal!="0") {
  64. linkageFilter2 += "town=" + vm.cityVal + ";";
  65. }
  66. var linkageFilter3 = "quotaDate >= '" + getHalfYearStartDate() + "' and quotaDate <= '" + getHalfYearEndDate() + "';";
  67. if(vm.cityVal!="0") {
  68. linkageFilter3 += "town=" + vm.cityVal + ";";
  69. }
  70. var linkageFilter4 = "quotaDate >= '" + getYearEndDate() + "' and quotaDate <= '" + getYearEndDate() + "';";
  71. // if(vm.cityVal!="0") {
  72. // linkageFilter4 += "town=" + vm.cityVal + ";";
  73. // }
  74. var reqUrl = [{url: bigDataAPI.getCityArea,reqType: 'get',data: {}},
  75. {url: bigDataAPI.getNoChartTemplateData,reqType: 'get',data: {viewCodeStr: "VIEW_14_0011",linkageFilter:linkageFilter1}},//左上角-上月
  76. {url: bigDataAPI.getNoChartTemplateData,reqType: 'get',data: {viewCodeStr: "VIEW_14_0011",linkageFilter:linkageFilter2}},//左上角-本年
  77. {url: bigDataAPI.getNoChartTemplateData,reqType: 'get',data: {viewCodeStr: "VIEW_14_0012",linkageFilter:linkageFilter4}},
  78. {url: bigDataAPI.getNoChartTemplateData,reqType: 'get',data: {viewCodeStr: "VIEW_14_0013",linkageFilter:linkageFilter3}},//
  79. {url: bigDataAPI.getNoChartTemplateData,reqType: 'get',data: {viewCodeStr: "VIEW_14_0014",linkageFilter:linkageFilter3}},//
  80. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: "VIEW_14_0015",linkageFilter:linkageFilter3}},//门诊人次月趋势
  81. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: "VIEW_14_0016",linkageFilter:linkageFilter3}},//住院人次月趋势
  82. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: "VIEW_14_0017",linkageFilter:linkageFilter3}},//门诊分类别月趋势
  83. {url: bigDataAPI.getTemplateDataByViewCode,reqType: 'get',data: {viewCode: "VIEW_14_0018",linkageFilter:linkageFilter3}},//住院平均日数月趋势
  84. {url:bigDataAPI.getMapJingWeiDuInfo,reqType: 'get',data:{}},//上饶地图经纬度数据
  85. ];
  86. httpRequest.getReqPromises(reqUrl).then(function(datas) {
  87. vm.town = [{
  88. "name": "上饶市",
  89. "id": "0"
  90. }].concat(datas[0]);
  91. vm.leftData1 = datas[1];
  92. vm.leftData2 = datas[2];
  93. data3 = datas[3];
  94. data4 = datas[4];
  95. data5 = datas[5];
  96. data6 = datas[6];
  97. data7 = datas[7];
  98. data8 = datas[8];
  99. data9 = datas[9];
  100. data10 = datas[10];
  101. vm.setLeftChart1(data6);
  102. vm.setLeftChart2(data7);
  103. vm.setRightChart1(data8);
  104. vm.setRightChart2(data9);
  105. vm.setTable1(data4);
  106. vm.setTable2(data5);
  107. vm.setleftData1();
  108. echarts.registerMap('上饶',data10);
  109. vm.setMapData(data3);
  110. vm.setYesterDay(data3);
  111. $(".div-mask-layer").hide();
  112. })
  113. },
  114. setleftData1: function() {
  115. var options = {},options1={},options2={},vm=this;
  116. if(this.leftData1.successFlg) {
  117. _.map(vm.leftData1.obj.VIEW_14_0011,function(item,index){
  118. if(vm.cityVal=="0"){//上饶市
  119. options1 = vm.leftData1.obj.VIEW_14_0011[0];
  120. }else if(item.firstColumn==vm.city){
  121. options1 = item;
  122. }
  123. })
  124. }
  125. if(this.leftData2.successFlg) {
  126. _.map(vm.leftData2.obj.VIEW_14_0011,function(item,index){
  127. if(vm.cityVal=="0"){//上饶市
  128. options2 = vm.leftData2.obj.VIEW_14_0011[0];
  129. }else if(item.firstColumn==vm.city){
  130. options2 = item;
  131. }
  132. })
  133. }
  134. vm.bakLeftData1 = this.setFormater(options1);
  135. vm.bakLeftData2 = this.setFormater(options2);
  136. this.leftData = vm.bakLeftData1;
  137. },
  138. setYesterDay: function(data3) {
  139. var options = {},vm=this;
  140. if(data3.successFlg) {
  141. _.map(data3.obj&&data3.obj.VIEW_14_0012||[],function(item,index){
  142. if(vm.cityVal=="0"){//上饶市
  143. options = data3.obj.VIEW_14_0012[0];
  144. }else if(item.firstColumn==vm.city){
  145. options = item;
  146. }
  147. })
  148. }
  149. if(options){
  150. this.setFormater(options);
  151. this.yesterdayData = options;
  152. }
  153. },
  154. setLeftChart1: function(data6) {
  155. var options = null;
  156. var options = data6.successFlg?data6.obj.viewInfos&&JSON.parse(data6.obj.viewInfos[0].options[0].option):{};
  157. if(options&&options.series && options.series[0].data && options.series[1].data){
  158. options = leftChart1DataFormat(options);
  159. this.leftChart1 = options;
  160. this.hasData1 = true;
  161. }else{
  162. this.hasData1 = false;
  163. }
  164. },
  165. setLeftChart2: function(data7) {
  166. var options = null;
  167. var options = data7.successFlg?data7.obj.viewInfos&&JSON.parse(data7.obj.viewInfos[0].options[0].option):{};
  168. if(options&&options.series && options.series[0].data && options.series[1].data){
  169. options = leftChart2DataFormat(options);
  170. this.leftChart2 = options;
  171. this.hasData2 = true;
  172. }else{
  173. this.hasData2 = false;
  174. }
  175. },
  176. setMapData: function(data3) {
  177. var optionData = [];
  178. _.map(data3.obj&&data3.obj.VIEW_14_0012||[], function(item) {
  179. if(item.firstColumn != "合计") {
  180. optionData.push({
  181. name: item.townName,
  182. value: parseInt(item.HC_14_1019)
  183. })
  184. }
  185. })
  186. if(optionData.length>0){
  187. var options = optionData;
  188. this.mapData = {
  189. data: options,
  190. index: this.lineHeightIndex
  191. };
  192. this.hasMapData = true;
  193. }else{
  194. this.hasMapData = false;
  195. }
  196. },
  197. setRightChart1: function(data8) {
  198. var options = null;
  199. var options = data8.successFlg?data8.obj.viewInfos&&JSON.parse(data8.obj.viewInfos[0].options[0].option):{};
  200. if(options&&options.series && options.series[0].data && options.series[1].data && options.series[2].data && options.series[3].data){
  201. options = rightChart1DataFormat(options);
  202. this.rightChart1 = options
  203. this.hasData4 = true;
  204. $(".right1 .contentBox3").removeClass("div-menzhenfenleibei");
  205. }else{
  206. this.hasData4 = false;
  207. $(".right1 .contentBox3").addClass("div-menzhenfenleibei");
  208. }
  209. },
  210. setRightChart2: function(data9) {
  211. var options = null;
  212. var options = data9.successFlg?data9.obj.viewInfos&&JSON.parse(data9.obj.viewInfos[0].options[0].option):{};
  213. if(options&&options.series && options.series[0].data && options.series[1].data){
  214. options = rightChart2DataFormat(options);
  215. this.rightChart2 = options
  216. this.hasData6 = true;
  217. $(".right2 .contentBox3").removeClass("div-menzhenfenleibei");
  218. }else{
  219. this.hasData6 = false;
  220. $(".right2 .contentBox3").addClass("div-menzhenfenleibei");
  221. }
  222. },
  223. setTable1: function(data4) {
  224. var resData = [];
  225. var data = data4.successFlg?data4.obj.VIEW_14_0013:[];
  226. _.map(data, function(item, index) {
  227. if(item.firstColumn != "合计" && item.month) {
  228. item.month = parseInt(item.month.substring(5, 7))+"月";
  229. resData.push(item)
  230. }
  231. })
  232. if(resData.length==0){
  233. this.hasData3 = false;
  234. }else{
  235. this.hasData3 = true;
  236. this.tableData1 = resData
  237. }
  238. },
  239. setTable2: function(data5) {
  240. var resData = [];
  241. var data = data5.successFlg?data5.obj.VIEW_14_0014:[];
  242. _.map(data, function(item, index) {
  243. if(item.firstColumn != "合计" && item.month) {
  244. item.month = parseInt(item.month.substring(5, 7))+"月";
  245. resData.push(item)
  246. }
  247. })
  248. if(resData.length==0){
  249. this.hasData5 = false;
  250. }else{
  251. this.hasData5 = true;
  252. this.tableData2 = resData
  253. }
  254. },
  255. setCity(item) {
  256. this.city = item.name;
  257. },
  258. setTimeStr(v) {
  259. this.timeType = v;
  260. this.timeType == 1?this.leftData=this.bakLeftData1:this.leftData=this.bakLeftData2;
  261. },
  262. setFormater: function(obj) {
  263. for(var c in obj) {
  264. if(obj[c].toString().indexOf(",") == -1){//不存在,,说明要格式化
  265. var re = /^[0-9]+.?[0-9]*/;//判断字符串是否为数字//判断正整数/[1−9]+[0−9]∗]∗/
  266. if (!re.test(obj[c])) { //不是数字,则不格式化
  267. continue;
  268. }
  269. if(obj[c]>100000){
  270. obj[c] = (obj[c]/10000).toFixed(2)+"万"
  271. }else{
  272. obj[c] = toThousands(obj[c]);
  273. }
  274. }
  275. }
  276. return obj;
  277. },
  278. newObj: function(obj) {
  279. return JSON.parse(JSON.stringify(obj))
  280. },
  281. clickMap: function(res) {
  282. this.city = res.name;
  283. },
  284. skipClick: function() {
  285. console.log(222)
  286. this.skipShow == 0 ? this.skipShow = 1 : this.skipShow = 0
  287. }
  288. },
  289. watch: {
  290. city: function(value) {
  291. var that = this;
  292. that.lineHeightIndex = value;
  293. this.initData();
  294. }
  295. }
  296. });
  297. //数字格式化
  298. function toThousands(str) {
  299. if(!str) return
  300. str = parseInt(str);
  301. if(typeof(str) == 'number') str = str.toString()
  302. var newStr = "";
  303. var count = 0;
  304. if(str.indexOf(".") == -1) {
  305. for(var i = str.length - 1; i >= 0; i--) {
  306. if(count % 3 == 0 && count != 0) {
  307. newStr = str.charAt(i) + "," + newStr;
  308. } else {
  309. newStr = str.charAt(i) + newStr;
  310. }
  311. count++;
  312. }
  313. str = newStr;
  314. } else {
  315. for(var i = str.indexOf(".") - 1; i >= 0; i--) {
  316. if(count % 3 == 0 && count != 0) {
  317. newStr = str.charAt(i) + "," + newStr;
  318. } else {
  319. newStr = str.charAt(i) + newStr; //逐个字符相接起来
  320. }
  321. count++;
  322. }
  323. str = newStr + (str + "00").substr((str + "00").indexOf("."), 3);
  324. }
  325. return str;
  326. }
  327. document.getElementById("full").onclick = function (event) {
  328. var app = document.getElementById('app');
  329. console.log()
  330. if($("#full").attr('src') == "../images/full-q.png"){
  331. $("#full").attr('src',"../images/full-s.png")
  332. FullScreen(app);
  333. }else{
  334. $("#full").attr('src',"../images/full-q.png")
  335. exitfullscreen()
  336. }
  337. }
  338. function FullScreen() {
  339. var el = document.documentElement;
  340. var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen; //定义不同浏览器的全屏API
  341. //执行全屏
  342. if (typeof rfs != "undefined" && rfs) {
  343. debugger
  344. rfs.call(el);
  345. } else if (typeof window.ActiveXObject != "undefined") {
  346. var wscript = new ActiveXObject("WScript.Shell");
  347. if (wscript != null) {
  348. debugger
  349. wscript.SendKeys("{F11}");
  350. }
  351. }
  352. }
  353. function exitfullscreen() { //退出全屏
  354. if (document.exitFullscreen) {
  355. document.exitFullscreen();
  356. }
  357. else if (document.mozCancelFullScreen) {
  358. document.mozCancelFullScreen();
  359. }
  360. else if (document.webkitCancelFullScreen) {
  361. document.webkitCancelFullScreen();
  362. }
  363. else if (document.msExitFullscreen) {
  364. document.msExitFullscreen();
  365. }
  366. }